Prettier iterator implementations in D?
Bill Baxter
dnewsgroup at billbaxter.com
Thu Oct 19 22:25:51 PDT 2006
Unknown W. Brackets wrote:
> Shorter and more beautiful is good, and has merits indeed...
>
> But sometimes clarity comes as a price, and that's not so good. If I
> were new to D, this:
>
> void opApply( (inout uint) block)
>
> Would look like a funky sort of cast.
Well if you're new to D then there's a whole *lot* of things that are
going to look funky. Like foo!(int)() -- looks like some kind of
negation of a cast of nothing. Funky!
> That said, this:
>
> void opApply( ) |inout uint|
>
> Is at least clear, if not horrendously ugly to my eyes.
I agree that it's not so ugly, but I don't think it's any clearer unless
you've been reading Ruby code. And it doesn't have any analogues
anywhere else in D. At least leaving out the keyword 'delegate' and the
keyword 'void' is already sanctioned practice elsewhere in D. Being
able to leave it out on variable declarations actually makes things
*more* consistent.
--bb
More information about the Digitalmars-d
mailing list