Thread overview | ||||||
---|---|---|---|---|---|---|
|
July 29, 2004 Iterator and algorithm example | ||||
---|---|---|---|---|
| ||||
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 |
July 29, 2004 Re: Iterator and algorithm example | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | "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 > > > Sean I 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>) |
July 30, 2004 Re: Iterator and algorithm example | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew | 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 |
July 30, 2004 Re: Iterator and algorithm example | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | "Sean Kelly" <sean@f4.ca> wrote in message news:cec34p$1uar$1@digitaldaemon.com... > 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. Good. As long as I've at least one person that agrees with me, I know I'm not completely barking. > > >(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 :) Cool, mate. No worries. :) |
Copyright © 1999-2021 by the D Language Foundation