The great compromise of the D standard library
Reiner Pope
some at address.com
Fri Oct 19 05:14:24 PDT 2007
Bill Baxter wrote:
> Bruce Adams wrote:
>> Bill Baxter Wrote:
>>
>>> Darryl B wrote:
>>>> == Quote from Ender KaShae (astrothayne at gmail.com)'s article
>>>>> I have great misgivings over the divide among the D community
>>>>> between standard
>>>> libriraries. The contintion will no doubt eventually lead to a
>>>> schism reduce the
>>>> reusibility of D code.
>>>>
>>>> I absolutely agree with this point. One of the first eyebrow-raising
>>>> experiences
>>>> for me, moving to D, was learning of this 'alternate' standard
>>>> library. The 'D'
>>>> standard library should be 'the' D standard library, shouldn't it?
>>>> You may as well
>>>> be writing in a different language, going from one lib to the other.
>>>> You really
>>>> have to specify which 'flavor' of D you use when speaking to others,
>>>> and a Tango
>>>> dev may not even want to look at a problem someone has if they were
>>>> using Phobos.
>>>> The separation of the 'D-Tango' and 'D-Phobos' factions is
>>>> detrimental to the D
>>>> language as a whole, IMO.
>>> There's also D2.0 which is a completely different, incompatible
>>> version of D. So really there are *three* different incompatible
>>> versions of D to choose from right now (yes you can get some source
>>> code to compile with both D1 and D2, just like you can get some code
>>> to compile with either Tango or Phobos).
>>>
>>> I was all for adding of const to D, but my vision was for it to get
>>> added relatively quickly and become the one-and-only D. Add it
>>> quickly, get everyone to fix their code, and then forget there ever
>>> was a D without const. Leave it in the dust. Just like we forgot
>>> about D with regular expression literals, or D with the === operator.
>>>
>>> But instead we got a D-without-const codified as a permanent,
>>> unchanging standard and D-with-const as a new, incompatible,
>>> competing standard.
>>>
>>> Taking a step back it just seems really silly for a niche language
>>> like D to have so many factions.
>>>
>>> So here's a little proposal to maybe help mend the D1/D2 schism a
>>> bit: add -v2 compatiblity switch to D1 that would cause it to just
>>> ignore D2's const and invariant declarations. That would make
>>> writing code that works on both a lot easier.
>>>
>>> After porting a bit of D2's std.* to D1, it seems that the main
>>> issues are just const(foo)[] and invariant(foo)[] constructs here and
>>> there. The fix is almost always just to remove them. So if the D1
>>> compiler could be made to ignore those then that would remove most of
>>> the hassle of making code compatible between D1 and D2.
>>>
>>> --bb
>>
>> Is this really worth the hassle? If you check Walter's recent postings
>> sorting out const is on the list for the next release. He know's it
>> sucks, he started a thread on it remember. I don't think we have long
>> to wait for the next try. He could get it wrong again but given all
>> the feedback and some time to think maybe he's got it right this time
>> (or at least right enough).
>
> D1.0 is still intended as a long-term support, stable version of D. So
> D1.0 is not going away for a while even if const turns into everybody's
> favorite feature of D2.0. And even if the new const design has
> everybody doing backflips of joy, code written using it it will still be
> incompatible with D1.0, and making it compatible will still be a pain
> since D lacks the equivalent of something like
> #define invariant /*nothing*/
>
> --bb
For what it's worth, something like this should probably work
template Const(T)
{
version (D1)
mixin("alias const(T) Const;");
else
mixin("alias T Const;");
}
-- Reiner
More information about the Digitalmars-d
mailing list