digitalmars.D - Better slicing
- NN <NN_member pathlink.com> Mar 08 2006
- Hasan Aljudy <hasan.aljudy gmail.com> Mar 08 2006
- Tom <Tom_member pathlink.com> Mar 08 2006
- "Lionello Lunesu" <lio remove.lunesu.com> Mar 08 2006
- Oskar Linde <oskar.lindeREM OVEgmail.com> Mar 09 2006
- "Lionello Lunesu" <lio remove.lunesu.com> Mar 10 2006
- Bruno Medeiros <daiphoenixNO SPAMlycos.com> Mar 09 2006
- Sean Kelly <sean f4.ca> Mar 09 2006
What about more powerful slicing, like e.g. in Python ? char[] x; char[] y = x[0 : x.size : 1]; char[] y = x[x.size : 1]; // Same char[] z = x[x.size : 0 : -1]; // Reverse char[] z = x[x.size :: -1]; // Same // Maybe with D syntax char[] x; char[] y = x[0 .. x.size .. 1]; char[] y = x[x.size .. 1]; // Same char[] z = x[x.size .. 0 .. -1]; // Reverse char[] z = x[x.size .. .. -1]; // Same
Mar 08 2006
NN wrote:What about more powerful slicing, like e.g. in Python ? <snip> char[] y = x[0 .. x.size .. 1];
What's that supposed to mean?
Mar 08 2006
In article <dun61g$30be$1 digitaldaemon.com>, NN says...What about more powerful slicing, like e.g. in Python ? char[] x; char[] y = x[0 : x.size : 1]; char[] y = x[x.size : 1]; // Same char[] z = x[x.size : 0 : -1]; // Reverse char[] z = x[x.size :: -1]; // Same // Maybe with D syntax char[] x; char[] y = x[0 .. x.size .. 1]; char[] y = x[x.size .. 1]; // Same char[] z = x[x.size .. 0 .. -1]; // Reverse char[] z = x[x.size .. .. -1]; // Same
I think it's enough how it is now. We'll never reach 1.0 if we keep adding "luxuries" to the language, of course it's my humble oppinion. Instead I would suggest to complete unfinished features, fix bugs and, if it is possible, to make the almighty constness implementation in some way ;-). Tom;
Mar 08 2006
Tom wrote:In article <dun61g$30be$1 digitaldaemon.com>, NN says...What about more powerful slicing, like e.g. in Python ? char[] x; char[] y = x[0 : x.size : 1]; char[] y = x[x.size : 1]; // Same char[] z = x[x.size : 0 : -1]; // Reverse char[] z = x[x.size :: -1]; // Same // Maybe with D syntax char[] x; char[] y = x[0 .. x.size .. 1]; char[] y = x[x.size .. 1]; // Same char[] z = x[x.size .. 0 .. -1]; // Reverse char[] z = x[x.size .. .. -1]; // Same
I think it's enough how it is now. We'll never reach 1.0 if we keep adding "luxuries" to the language, of course it's my humble oppinion. Instead I would suggest to complete unfinished features, fix bugs and, if it is possible, to make the almighty constness implementation in some way ;-).
I agree. I think we can already do all these with the currently implemented slicing and .reverse-operations. The syntax with negative indices IMHO doesn't fit in D. -- Jari-Matti
Mar 08 2006
To reverse an array is a costly operation, and it would not be a good idea to hide it behind a fancy operator, it will hide the penalty. L. "NN" <NN_member pathlink.com> wrote in message news:dun61g$30be$1 digitaldaemon.com...What about more powerful slicing, like e.g. in Python ? char[] x; char[] y = x[0 : x.size : 1]; char[] y = x[x.size : 1]; // Same char[] z = x[x.size : 0 : -1]; // Reverse char[] z = x[x.size :: -1]; // Same // Maybe with D syntax char[] x; char[] y = x[0 .. x.size .. 1]; char[] y = x[x.size .. 1]; // Same char[] z = x[x.size .. 0 .. -1]; // Reverse char[] z = x[x.size .. .. -1]; // Same
Mar 08 2006
Lionello Lunesu wrote:"NN" <NN_member pathlink.com> wrote in message news:dun61g$30be$1 digitaldaemon.com...What about more powerful slicing, like e.g. in Python ? char[] x; char[] y = x[0 : x.size : 1]; char[] y = x[x.size : 1]; // Same char[] z = x[x.size : 0 : -1]; // Reverse char[] z = x[x.size :: -1]; // Same // Maybe with D syntax char[] x; char[] y = x[0 .. x.size .. 1]; char[] y = x[x.size .. 1]; // Same char[] z = x[x.size .. 0 .. -1]; // Reverse char[] z = x[x.size .. .. -1]; // Same
This has similarities to Norbert Nemec's suggestion from 2 years ago: http://homepages.uni-regensburg.de/~nen10015/documents/D-multidimarray.htmlTo reverse an array is a costly operation, and it would not be a good idea to hide it behind a fancy operator, it will hide the penalty.
Reversing arrays doesn't have to be expensive if you have strided array references. (By this, I'm not suggesting that D should make simple 1-D dynamic arrays strided.) (Sorry for reversing the top-posting.) /Oskar
Mar 09 2006
To reverse an array is a costly operation, and it would not be a good idea to hide it behind a fancy operator, it will hide the penalty.
Reversing arrays doesn't have to be expensive if you have strided array references. (By this, I'm not suggesting that D should make simple 1-D dynamic arrays strided.)
How does striding improve a reverse on a 1-D array?(Sorry for reversing the top-posting.)
No problem, it makes more sense :) L.
Mar 10 2006
NN wrote:What about more powerful slicing, like e.g. in Python ?
-- Bruno Medeiros - CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Mar 09 2006
NN wrote:What about more powerful slicing, like e.g. in Python ?
I thought about this while reading up on Ruby recently, but I like that the current syntax doesn't have any 'hidden' costs associated with it--no memory is allocated, functions run to manipulate data, etc. So I would not like to see slicing expanded, even if it would be convenient in some cases. Sean
Mar 09 2006









Hasan Aljudy <hasan.aljudy gmail.com> 