dst = src rather than src dst
Bill Baxter
dnewsgroup at billbaxter.com
Wed Sep 5 16:44:07 PDT 2007
Russell Lewis wrote:
> Bill Baxter wrote:
>> Robert Fraser wrote:
>>> Russell Lewis Wrote:
>>>
>>>> Let's take this one step further. Let's say that this is a typedef:
>>>> typedef dst = src.dup;
>>>> while this is an alias:
>>>> typedef dst = src;
>>>
>>> Please no!
>>
>> On second thought, let's take a step back again.
>> And forward
>> and back...
>> and then we're cha-cha-ing!
>
> Yeah, I felt the same way when the syntax first occurred to me: "EEK!
> RUN!" But it's growing on me. There is a certain elegance to the idea
> that a type is a compile-time variable, and that an alias is copying the
> (reference to) the type, while a typedef is creating a new type with the
> same contents (that is, the same semantics) as the old.
>
> But I still shudder when I see it. :)
Well, I didn't think it was a horrible idea, just not really necessary.
D already has a decent way to distinguish aliases vs definition new
types, and as far as I know it doesn't cause any consternation in daily
coding (basically you just never use the latter).
For a new language without any established conventions it might be a
nice idea to treat types more like values across the board, and I
believe there are languages that do exactly this (like lisp and python)
but I think it's too late for D to try to make such a big change.
Just reversing the order of arguments to alias and typedef and sticking
an '=' between them seems like a good value proposition to me. Decent
gain in readability and consistency, minimal pain in terms of old code
breakage (assuming old-style aliases remain allowed for a while.)
--bb
More information about the Digitalmars-d
mailing list