Food for thought
Johan Granberg
lijat.meREM at OVE.gmail.com
Tue Feb 13 04:26:52 PST 2007
Robby wrote:
> The implementation of array methods to me is one of the sexiest, and yet
> quietest features of D. Probably do to the duh factor, but none the
> less. (any method that has an array as the first argument can use a
> shortened syntax)
>
> how much machinery would it entail to make this avail to all basic types
> instead of just arrays? To me this would really allow me (and I'm
> assuming others) to improve readability of the code written, and while
> all basic types aren't object based, it allows us to treat them as
> objects in code. Or even treat them as if they were a struct (similar
> representation to C#'s basic types as struct idiom.
>
> consider a character example
> bool isLower(char c)
> {
> if ('a' <= c && c <= 'z')
> return true;
> return false;
> }
> While it's just as easy to have isLower('a') the readability comes in
> with 'a'.isLower()
>
> And if the methods could be treated as properties we could have
> something similar to
> 5.sqr (though I'd be just as thrilled with 5.sqr())
>
> So I'm asking, since there is base implementation for the machinery for
> arrays, how hard would it be to implement the machinery for all basic
> types?
>
> Is there any side effects to this I'm not thinking of?
>
> Would it be fair to consider that the compiler can optimize such cases?
Yes this is something I have wanted a long time.
Pleas implement this Walter.
More information about the Digitalmars-d
mailing list