Re: foreach syntax, std.mixin

2009-11-11 Thread Philippe Sigaud
On Wed, Nov 11, 2009 at 17:44, Philippe Sigaud wrote: > On Wed, Nov 11, 2009 at 16:48, dsimcha wrote: > >> If you uncomment a /*ref*/ in there somewhere, which was leftover from a >> compiler bug a long time ago, it seems to work. The real problem is that >> that bit >> of cruft hasn't been rem

Re: foreach syntax, std.mixin

2009-11-11 Thread Philippe Sigaud
On Wed, Nov 11, 2009 at 16:48, dsimcha wrote: > > *test it* > > Hmm, I can get enumerate to work, but the Unpack part doesn't compile. It > > complains elem.at!(0) is not an lvalue. > > Argh. That's because I was hacking around with Zip in my copy of Phobos > right > before I wrote this lib and

Re: foreach syntax, std.mixin

2009-11-11 Thread dsimcha
== Quote from Philippe Sigaud (philippe.sig...@gmail.com)'s article > --0016e6d99ba70494130478196284 > Content-Type: text/plain; charset=ISO-8859-1 > On Sun, Nov 8, 2009 at 22:43, dsimcha wrote: > > > > Hot off the press and VERY prototype-ish: > > > > Code: > > http://pastebin.com/m2087e524 > > >

Re: foreach syntax, std.mixin

2009-11-11 Thread Philippe Sigaud
On Sun, Nov 8, 2009 at 22:43, dsimcha wrote: > > Hot off the press and VERY prototype-ish: > > Code: > http://pastebin.com/m2087e524 > > Docs: > http://cis.jhu.edu/~dsimcha/unpackEnumerate.html > > Cool! Thanks a lot. I looked at opApply for D1

Re: foreach syntax, std.mixin

2009-11-09 Thread Bill Baxter
On Mon, Nov 9, 2009 at 6:46 AM, dsimcha wrote: > == Quote from Bill Baxter (wbax...@gmail.com)'s article >> I agree.  Those numbers don't seem so bad, particularly if inlining is >> possible in the future. >> But there's still the issue of how to get both an enumeration and an >> unpacked tuple to

Re: foreach syntax, std.mixin

2009-11-09 Thread dsimcha
== Quote from Bill Baxter (wbax...@gmail.com)'s article > I agree. Those numbers don't seem so bad, particularly if inlining is > possible in the future. > But there's still the issue of how to get both an enumeration and an > unpacked tuple together. > --bb Yeah, I thought about this, and I didn

Re: foreach syntax, std.mixin

2009-11-09 Thread Bill Baxter
On Sun, Nov 8, 2009 at 5:13 PM, dsimcha wrote: > == Quote from Bill Baxter (wbax...@gmail.com)'s article >> On Sun, Nov 8, 2009 at 1:43 PM, dsimcha wrote: >> > == Quote from Philippe Sigaud (philippe.sig...@gmail.com)'s article >> >> > dsimcha wrote: >> >> > Makes me wonder why noone thought of t

Re: foreach syntax, std.mixin

2009-11-08 Thread dsimcha
== Quote from Bill Baxter (wbax...@gmail.com)'s article > On Sun, Nov 8, 2009 at 1:43 PM, dsimcha wrote: > > == Quote from Philippe Sigaud (philippe.sig...@gmail.com)'s article > >> > dsimcha wrote: > >> > Makes me wonder why noone thought of this until now, or maybe someone > did > >> > and I > >

Re: foreach syntax, std.mixin

2009-11-08 Thread Bill Baxter
On Sun, Nov 8, 2009 at 1:43 PM, dsimcha wrote: > == Quote from Philippe Sigaud (philippe.sig...@gmail.com)'s article >> > dsimcha wrote: >> > Makes me wonder why noone thought of this until now, or maybe someone did >> > and I >> > forgot.  How's: >> > >> > foreach(fooElem, barElem; unpack(zip(foo

Re: foreach syntax, std.mixin

2009-11-08 Thread bearophile
Bill Baxter: > Or I suppose it could > be a special syntax in "foreach" for now. D has an already very large amount of "for now" inside. Let's start designing things correctly & tidy from the start instead, for a change (and let's generalize some of the already present things). Bye, bearophile

Re: foreach syntax, std.mixin

2009-11-08 Thread dsimcha
== Quote from Philippe Sigaud (philippe.sig...@gmail.com)'s article > > dsimcha wrote: > > Makes me wonder why noone thought of this until now, or maybe someone did > > and I > > forgot. How's: > > > > foreach(fooElem, barElem; unpack(zip(foo, bar))) {}, or: > > > > foreach(i, elem; enumerate(chai

Re: foreach syntax, std.mixin

2009-11-08 Thread Philippe Sigaud
On Sun, Nov 8, 2009 at 21:14, dsimcha wrote: > > function like in python. Which does something like > > zip(iota(1,bar.length),bar). > > > I think the index variant would better be done as an enumerate() > Enumerate is a great idea. It's probably much better than requiring every > range > struct

Re: foreach syntax, std.mixin

2009-11-08 Thread dsimcha
== Quote from Bill Baxter (wbax...@gmail.com)'s article > On Sun, Nov 8, 2009 at 9:10 AM, dsimcha wrote: > > What are the chances that D gets auto tuple unpacking for foreach loops b > efore > > D2 goes gold?  In other words, it would be nice to write: > > > > uint[] foo = [1,2,3,4,5]; > > uint[]

Re: foreach syntax, std.mixin

2009-11-08 Thread Bill Baxter
On Sun, Nov 8, 2009 at 9:10 AM, dsimcha wrote: > What are the chances that D gets auto tuple unpacking for foreach loops before > D2 goes gold?  In other words, it would be nice to write: > > uint[] foo = [1,2,3,4,5]; > uint[] bar = [6,7,8,9,10]; > > foreach(a, b; zip(foo, bar)) { >    // Does wha

foreach syntax, std.mixin

2009-11-08 Thread dsimcha
What are the chances that D gets auto tuple unpacking for foreach loops before D2 goes gold? In other words, it would be nice to write: uint[] foo = [1,2,3,4,5]; uint[] bar = [6,7,8,9,10]; foreach(a, b; zip(foo, bar)) { // Does what you think it does. } Also, how about foreach over ranges w