digitalmars.D - Iterator and algorithm example
- Sean Kelly (11/11) Jul 29 2004 A long time ago I suggested a way that iterators might work but then I n...
- Matthew (7/18) Jul 29 2004 I think your code perfectly exemplifies why, without implicit instantiat...
- Sean Kelly (6/11) Jul 29 2004 Yup. Don't take what I wrote to heart. I cranked 90% of that out in th...
- Matthew (4/15) Jul 29 2004 Good. As long as I've at least one person that agrees with me, I know I'...
A long time ago I suggested a way that iterators might work but then I never posted an example. In light of some of the issues that have arisen today, I thought it might be worthwhile to get some code up that folks could look at. I wrote this on the train on my way to work today so please forgive any oversights, but the code does work as provided. This example contains a basic list class (declaration is kind of odd to workaround what seems to be a scoping issue with private member data), some utility templates, and a very basic algorithm. The only real annoyance is the lack of implicit type deduction as it makes doing this stuff a lot more verbose. http://home.f4.ca/sean/d/iterator.d Sean
Jul 29 2004
"Sean Kelly" <sean f4.ca> wrote in message news:cebheo$1lsd$1 digitaldaemon.com...A long time ago I suggested a way that iterators might work but then I never posted an example. In light of some of the issues that have arisen today, I thought it might be worthwhile to get some code up that folks could look at. I wrote this on the train on my way to work today so please forgive any oversights, but the code does work as provided. This example contains a basic list class (declaration is kind of odd to workaround what seems to be a scoping issue with private member data), some utility templates, and a very basic algorithm. The only real annoyance is the lack of implicit type deduction as it makes doing this stuff a lot more verbose. http://home.f4.ca/sean/d/iterator.d SeanI think your code perfectly exemplifies why, without implicit instantiation, iterators are pretty worthless in D. I hope that was your intent. :) btw, there are a lot of things similar in that code to dtl/list.d. ;) (I do have some issues with some of the things you've done, but since it's merely an exemplifying piece, and I've not posted any DTL yet, it'd be churlish of me to carp on. Hopefully we can participate in a free exchange of ideas very soon. <g>)
Jul 29 2004
In article <cec1ml$1tlt$1 digitaldaemon.com>, Matthew says...I think your code perfectly exemplifies why, without implicit instantiation, iterators are pretty worthless in D. I hope that was your intent. :)Pretty much :) Just to show it's possible but irritating.(I do have some issues with some of the things you've done, but since it's merely an exemplifying piece, and I've not posted any DTL yet, it'd be churlish of me to carp on. Hopefully we can participate in a free exchange of ideas very soon. <g>)Yup. Don't take what I wrote to heart. I cranked 90% of that out in the hour I had on my way to work. It wasn't meant to be a stunning example of coding elegance :) Sean
Jul 29 2004
"Sean Kelly" <sean f4.ca> wrote in message news:cec34p$1uar$1 digitaldaemon.com...In article <cec1ml$1tlt$1 digitaldaemon.com>, Matthew says...hopeI think your code perfectly exemplifies why, without implicit instantiation, iterators are pretty worthless in D. IGood. As long as I've at least one person that agrees with me, I know I'm not completely barking.that was your intent. :)Pretty much :) Just to show it's possible but irritating.Cool, mate. No worries. :)(I do have some issues with some of the things you've done, but since it's merely an exemplifying piece, and I've not posted any DTL yet, it'd be churlish of me to carp on. Hopefully we can participate in a free exchange of ideas very soon. <g>)Yup. Don't take what I wrote to heart. I cranked 90% of that out in the hour I had on my way to work. It wasn't meant to be a stunning example of coding elegance :)
Jul 29 2004