Porting D2 code to D1
Bill Baxter
dnewsgroup at billbaxter.com
Thu Jul 17 22:07:56 PDT 2008
Ryan Bloomfield wrote:
> Jarrett Billingsley Wrote:
>
>> "Ryan Bloomfield" <_sir_maniacREMOVE_ME at yahoo.com> wrote in message
>> news:g5oct3$2vpl$1 at digitalmars.com...
>>
>>> Could a language construct be created in D1 and D2 to allow for a "lazy"
>>> version?
>> To be honest, I kind of wish this were the case with version statements all
>> the time.
>>
>>
>
> I disagree. I think it's good for all version blocks to compile under normal circumstances. If it didn't do that, uncompilable code could creep in. It would be especially bad if it involves machine-specific code. Coding between different versions of D is clearly going to be used less then the other intended uses of 'version'.
But it doesn't really solve the problem. So you have syntactically
correct code. Yippee. You still can't say whether it's semantically
valid until you actually compile it. So it provides protection from
code rot some of the time. But if you're worried about code rot,
syntactic validity is not enough. There's no substitute for actually
compiling and testing the code you want to have work.
If you're not worried about code rot then it's just a nuisance that gets
in the way of legitimate goals like making code portable between major
versions of D.
> Nevertheless, in my humble opinion, I do think the ability to ignore, or relax syntax rules needs to happen. Without it, any compiler or version specific feature could never be included in portable code. And compiler specific features seem to be the norm for C and C++ compilers.
In light of what I said above, I don't really see any point in forcing
versioned-out code to be syntactically valid like D does. It doesn't
protect you from what is probably the biggest classes of code rot
issues, which are things like variables getting renamed or functions
changing their number of parameters, etc.
--bb
More information about the Digitalmars-d
mailing list