digitalmars.D - Better slicing
- NN (12/12) Mar 08 2006 What about more powerful slicing, like e.g. in Python ?
- Hasan Aljudy (2/5) Mar 08 2006 What's that supposed to mean?
- Tom (6/18) Mar 08 2006 I think it's enough how it is now. We'll never reach 1.0 if we keep addi...
- =?ISO-8859-1?Q?Jari-Matti_M=E4kel=E4?= (6/30) Mar 08 2006 I agree. I think we can already do all these with the currently
- Lionello Lunesu (5/18) Mar 08 2006 To reverse an array is a costly operation, and it would not be a good id...
- Oskar Linde (8/30) Mar 09 2006 This has similarities to Norbert Nemec's suggestion from 2 years ago:
- Lionello Lunesu (3/9) Mar 10 2006 No problem, it makes more sense :)
- Bruno Medeiros (5/7) Mar 09 2006 No.
- Sean Kelly (7/8) Mar 09 2006 I thought about this while reading up on Ruby recently, but I like that
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]; // SameI 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...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-MattiWhat 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]; // SameI 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 ;-).
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...This has similarities to Norbert Nemec's suggestion from 2 years ago: http://homepages.uni-regensburg.de/~nen10015/documents/D-multidimarray.htmlWhat 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]; // SameTo 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
How does striding improve a reverse on a 1-D array?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.)(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 ?No. -- 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