Proposal: forward compatibility

Jason House jason.james.house at gmail.com
Sat Sep 6 07:33:44 PDT 2008


Denis Koroskin wrote:

> On Fri, 05 Sep 2008 09:57:40 +0400, Jason House
> <jason.james.house at gmail.com> wrote:
> 
>> D is an evolving language that does not restrict itself by requiring
>> backwards compatibility. Instead I propose that D adopt forward
>> compatibility...
>>
>> Specifically, allow D1 code to accept D2 code without doing extra
>> functionality. In D1, his would allow defining constants to be declared
>> with either const or invariant, object invariants to allow parenthesis,
>> and ignoring transitive const elements of type declarations.
>>
>> The goal is to not change the behavior of existing D1 code, but to
>> accept previously invalid D1 code. This should make the job of
>> maintaining a dual code base much easier.
> 
> I came up with the following constness solution:
> 
> First, define a Const!(T) template as follows:
> 
> ...
> 
> This would allow much easier D1/D2 migration without massive language
> changes.
> 
> What do you think?

I was worried that making a D1 compiler accept const in types declarations
would be a killer of the forward compatibility idea.  I think what you
propose for const type handling is a reasonable compromise.  It'd be easy
enough to write a Const!(T) and Invariant!(T) template.

I like how all the response to my proposal has been positive.  Sadly, it
can't go anywhere unless Walter likes the idea and he has yet to respond.



More information about the Digitalmars-d mailing list