digitalmars.D - Digital Mars Ate My Computer!
- Matthew Wilson (67/67) Jul 17 2004 You know you're pushing the language to the limits when you cause the
- Juanjo =?ISO-8859-15?Q?=C1lvarez?= (4/17) Jul 17 2004 It's not only powerful, it's easy and beautiful which is a very rare
- Charlie (5/22) Jul 17 2004 It does indeed look very cool, but why select, select0, select1, can the...
- Matthew (10/35) Jul 17 2004 Alas no. Walter has ruled out overloading of template and non-template m...
- Juanjo =?ISO-8859-15?Q?=C1lvarez?= (3/11) Jul 17 2004 Yes, but select_dlg (from delegate), select_mix, etc, are more descripti...
- Matthew (3/14) Jul 17 2004 Again, please don't worry about the names. All will be sorted in due cou...
- Juanjo =?ISO-8859-15?Q?=C1lvarez?= (2/7) Jul 18 2004 I hear Dennis Ritchie saying that about std C lib "creat" 30 years ago.....
- Matthew Wilson (7/14) Jul 18 2004 ;)
- John Reimer (4/8) Jul 17 2004 that are
- Matthew (11/28) Jul 17 2004 select() selects out those matching a given predicate, e.g. only selects...
- Juanjo =?ISO-8859-15?Q?=C1lvarez?= (7/41) Jul 17 2004 Maybe "transform" would be a better name than collect? When I first saw ...
- Matthew (7/48) Jul 17 2004 Sure. I've just borrowed the names from their Ruby counterparts - Ruby's...
- Blandger (12/18) Jul 18 2004 while
- J Anderson (4/11) Jul 23 2004 I have the same problem with enabling the -inline option.
You know you're pushing the language to the limits when you cause the compiler to eat your machine. I just had an unhappy 10 minutes waiting for my virtual memory to be completely eaten up by dmd.exe, and another 5 while I rebooted the oh-so-stable OS that is WinXP. Pleuch! Anyway, I think I've found a serious flaw in D's templates architecture. Here's the issue: In DTL, there are several different ways of treating containers, supporting different paradigms. The first, and most important one of these, is based on ranges, usually in combination with foreach. "In D-world, foreach is King!" (That's the title of a section in the book ... <g>). Containers provide a number of standard methods (some template, some non-template) that allow one to provide a filtered (sub-)set of their contents. The one I've been banging on about in other threads is select(), so we'll stick with that. Container { <range> select(<some function / predicate / function-object); This allows us to write something such as the following extract from my test suites: printf("\nselect()-ing the numbers, with IsOdd's fn, as a delegate\n"); foreach(int i; cont.select(&IsOdd.fn)) { printf("%d ", i); } printf("\n"); printf("\nselect()-ing the numbers, with IsEven\n"); foreach(int i; cont.select0!(IsEven)()) { printf("%d ", i); } printf("\n"); printf("\nselect()-ing the numbers, with DivisibleBy\n"); foreach(int i; cont.select1!(DivisibleBy)(new DivisibleBy(3))) { printf("%d ", i); } printf("\n"); These give: select()-ing the numbers, with IsOdd's fn, as a delegate -9 -7 -5 -3 -1 1 3 5 7 9 select()-ing the numbers, with IsEven -10 -8 -6 -4 -2 0 2 4 6 8 select()-ing the numbers, with DivisibleBy -9 -6 -3 0 3 6 9 Ok, that's nice, but that's not the whole picture. Given the set of methods that filter output of a given container exist (or, rather, they will when I've got it all working) in a mixin, the obvious - and intended!! - step is to mix-in the mixin to the range types themselves. This is to give the far more powerful composition of filters, e.g. foreach( . . . , container.select(&IsEven).collect(&Multiply).reject0!(DivisibleBy)(new DivisibleBy(3))) { } or (the more accessible): container.select(&IsEven).max(); I trust you'll agree this a very powerful model, (almost) matching the declarative notation of some of the power powerful (albeit barely compilable) stuff in bleeding edge C++. Unfortunately, there's a fly in my ointment. Because D appears to evaluate the types generated ( / generatable), it gets in an infinite loop here. This does not happen in C++. I don't know what the answer is, other than this aspect of the language, or the current compiler's interpretation of it, should be changed. I'll try and boil this down to a simple example and post it soon.
Jul 17 2004
Matthew Wilson wrote:container.select(&IsEven).collect(&Multiply).reject0!(DivisibleBy)(new DivisibleBy(3))) { } or (the more accessible): container.select(&IsEven).max(); I trust you'll agree this a very powerful model, (almost) matching the declarative notation of some of the power powerful (albeit barely compilable) stuff in bleeding edge C++.It's not only powerful, it's easy and beautiful which is a very rare combination nowadays. Man, your DTL have earned a new fan today :) Only a question, what does collect do?
Jul 17 2004
It does indeed look very cool, but why select, select0, select1, can they not fit under the same umbrella ? Charlie In article <cdbb5b$1b41$1 digitaldaemon.com>, Juanjo =?ISO-8859-15?Q?=C1lvarez?= says...Matthew Wilson wrote:container.select(&IsEven).collect(&Multiply).reject0!(DivisibleBy)(new DivisibleBy(3))) { } or (the more accessible): container.select(&IsEven).max(); I trust you'll agree this a very powerful model, (almost) matching the declarative notation of some of the power powerful (albeit barely compilable) stuff in bleeding edge C++.It's not only powerful, it's easy and beautiful which is a very rare combination nowadays. Man, your DTL have earned a new fan today :) Only a question, what does collect do?
Jul 17 2004
"Charlie" <Charlie_member pathlink.com> wrote in message news:cdbpbp$1g1r$1 digitaldaemon.com...It does indeed look very cool, but why select, select0, select1, can they not fit under the same umbrella ?Alas no. Walter has ruled out overloading of template and non-template member functions. There may be another way, of course. We're wandering out onto a new planet here, and people may be able to find paths I can't see. I very much want to get over the few language/compiiler hurdles that are holding me up, and then release 0.1, so all you smart(er) people can point out easier paths to me. :)Charlie In article <cdbb5b$1b41$1 digitaldaemon.com>, Juanjo=?ISO-8859-15?Q?=C1lvarez?=says...Matthew Wilson wrote:container.select(&IsEven).collect(&Multiply).reject0!(DivisibleBy)(new DivisibleBy(3))) { } or (the more accessible): container.select(&IsEven).max(); I trust you'll agree this a very powerful model, (almost) matching the declarative notation of some of the power powerful (albeit barely compilable) stuff in bleeding edge C++.It's not only powerful, it's easy and beautiful which is a very rare combination nowadays. Man, your DTL have earned a new fan today :) Only a question, what does collect do?
Jul 17 2004
Matthew wrote:"Charlie" <Charlie_member pathlink.com> wrote in message news:cdbpbp$1g1r$1 digitaldaemon.com...Yes, but select_dlg (from delegate), select_mix, etc, are more descriptive names.It does indeed look very cool, but why select, select0, select1, can they not fit under the same umbrella ?Alas no. Walter has ruled out overloading of template and non-template member functions.
Jul 17 2004
"Juanjo Álvarez" <juanjuxNO SPAMyahoo.es> wrote in message news:cdcfrh$1pei$3 digitaldaemon.com...Matthew wrote:Again, please don't worry about the names. All will be sorted in due course. :-)"Charlie" <Charlie_member pathlink.com> wrote in message news:cdbpbp$1g1r$1 digitaldaemon.com...Yes, but select_dlg (from delegate), select_mix, etc, are more descriptive names.It does indeed look very cool, but why select, select0, select1, can they not fit under the same umbrella ?Alas no. Walter has ruled out overloading of template and non-template member functions.
Jul 17 2004
Matthew wrote:I hear Dennis Ritchie saying that about std C lib "creat" 30 years ago... ;)Yes, but select_dlg (from delegate), select_mix, etc, are more descriptive names.Again, please don't worry about the names. All will be sorted in due course. :-)
Jul 18 2004
"Juanjo Álvarez" <juanjuxNO SPAMyahoo.es> wrote in message news:cddoaq$29c4$1 digitaldaemon.com...Matthew wrote:;) He he. Well, I tell you, the amount of compiler/language hassles I've had over the last four days, I've had to keep reminding myself that this is a new language. If it was otherwise, I'd have thrown my hands up and gone and written some VB!I hear Dennis Ritchie saying that about std C lib "creat" 30 years ago...Yes, but select_dlg (from delegate), select_mix, etc, are more descriptive names.Again, please don't worry about the names. All will be sorted in due course. :-)
Jul 18 2004
On Sun, 18 Jul 2004 06:37:30 +1000, Matthew wrote: <snip>I very much want to get over the few language/compiiler hurdlesthat areholding me up, and then release 0.1, so all you smart(er) people can point out easier paths to me. :)LOL! Smart answer! :-D
Jul 17 2004
"Juanjo Álvarez" <juanjuxNO SPAMyahoo.es> wrote in message news:cdbb5b$1b41$1 digitaldaemon.com...Matthew Wilson wrote:select() selects out those matching a given predicate, e.g. only selects those that are even collect() transforms all elements using a given transformation function, e.g. multiplies them by 3 reject() is the opposite of select(). It works by applying the Not!() template predicate and returns a Not'ed range otherwise identical to select(). The names for all these operations are borrowed from Ruby, and are open to change once it's released. It's the mechanisms that I'm interested in - and losing my hair over - at the moment. :)container.select(&IsEven).collect(&Multiply).reject0!(DivisibleBy)(new DivisibleBy(3))) { } or (the more accessible): container.select(&IsEven).max(); I trust you'll agree this a very powerful model, (almost) matching the declarative notation of some of the power powerful (albeit barely compilable) stuff in bleeding edge C++.It's not only powerful, it's easy and beautiful which is a very rare combination nowadays. Man, your DTL have earned a new fan today :) Only a question, what does collect do?
Jul 17 2004
Matthew wrote:"Juanjo Álvarez" <juanjuxNO SPAMyahoo.es> wrote in message news:cdbb5b$1b41$1 digitaldaemon.com...Maybe "transform" would be a better name than collect? When I first saw the code I thought "collect(&Multiply)" would be multipliying all the values and returning the outcome (collecting all the values on a single one). Maybe it's because english is (obviously :) not my native language and in my language (spanish) the word closer to "collect" (recolectar) means "to join" or "to take together".Matthew Wilson wrote:select() selects out those matching a given predicate, e.g. only selects those that are even collect() transforms all elements using a given transformation function, e.g. multiplies them by 3 reject() is the opposite of select(). It works by applying the Not!() template predicate and returns a Not'ed range otherwise identical to select(). The names for all these operations are borrowed from Ruby, and are open to change once it's released. It's the mechanisms that I'm interested in - and losing my hair over - at the moment. :)container.select(&IsEven).collect(&Multiply).reject0!(DivisibleBy)(new DivisibleBy(3))) { } or (the more accessible): container.select(&IsEven).max(); I trust you'll agree this a very powerful model, (almost) matching the declarative notation of some of the power powerful (albeit barely compilable) stuff in bleeding edge C++.It's not only powerful, it's easy and beautiful which is a very rare combination nowadays. Man, your DTL have earned a new fan today :) Only a question, what does collect do?
Jul 17 2004
"Juanjo Álvarez" <juanjuxNO SPAMyahoo.es> wrote in message news:cdcfpg$1pei$2 digitaldaemon.com...Matthew wrote:Sure. I've just borrowed the names from their Ruby counterparts - Ruby's my current fave language <g> - and they most certainly will be up for review/standardisation. We're just not at that stage of the game, and I wanted something established so as not to focus on that issue at the moment. Rest assured, I'm a *big* fan of unambiguous naming conventions. :-)"Juanjo Álvarez" <juanjuxNO SPAMyahoo.es> wrote in message news:cdbb5b$1b41$1 digitaldaemon.com...Maybe "transform" would be a better name than collect? When I first saw the code I thought "collect(&Multiply)" would be multipliying all the values and returning the outcome (collecting all the values on a single one). Maybe it's because english is (obviously :) not my native language and in my language (spanish) the word closer to "collect" (recolectar) means "to join" or "to take together".Matthew Wilson wrote:select() selects out those matching a given predicate, e.g. only selects those that are even collect() transforms all elements using a given transformation function, e.g. multiplies them by 3 reject() is the opposite of select(). It works by applying the Not!() template predicate and returns a Not'ed range otherwise identical to select(). The names for all these operations are borrowed from Ruby, and are open to change once it's released. It's the mechanisms that I'm interested in - and losing my hair over - at the moment. :)container.select(&IsEven).collect(&Multiply).reject0!(DivisibleBy)(new DivisibleBy(3))) { } or (the more accessible): container.select(&IsEven).max(); I trust you'll agree this a very powerful model, (almost) matching the declarative notation of some of the power powerful (albeit barely compilable) stuff in bleeding edge C++.It's not only powerful, it's easy and beautiful which is a very rare combination nowadays. Man, your DTL have earned a new fan today :) Only a question, what does collect do?
Jul 17 2004
"Matthew Wilson" <admin.hat stlsoft.dot.org> wrote in message news:cdat7l$176e$1 digitaldaemon.com...You know you're pushing the language to the limits when you cause the compiler to eat your machine. I just had an unhappy 10 minutes waiting for my virtual memory to be completely eaten up by dmd.exe, and another 5whileI rebooted the oh-so-stable OS that is WinXP. Pleuch!I've encountered the same problem. Recently I've converted and added some event processing java code to the DWT and got the same result. Shortly speaking adding only one new class 'private import' into the one 'old source file' force DMD 0.95 go to the infinite loop and it gives 'out of memory' error after a few minutes. I hadn't to reboot the PC though.Anyway, I think I've found a serious flaw in D's templates architecture.May be it's not only 'D's templates architecture' issue. --- Yuriy.
Jul 18 2004
Blandger wrote:I have the same problem with enabling the -inline option. -- -Anderson: http://badmama.com.au/~anderson/Anyway, I think I've found a serious flaw in D's templates architecture.May be it's not only 'D's templates architecture' issue. --- Yuriy.
Jul 23 2004