Language Versioning

Jacob Carlborg doob at me.com
Thu Apr 4 17:55:09 UTC 2019


On 2019-04-04 14:38, Jonathan Marler wrote:
> This is an informal proposal to add a versioning scheme to the D 
> Language.  If you'd like to take the time to read, please let everyone 
> know your thoughts and suggestions for the idea.  To Walter and Andrei, 
> please let me know your thoughts, if you think the idea has merit and if 
> so what the next steps should be (i.e. DIP/PR/More Resarch Discussion 
> Needed).
> 
> As I've been thinking about various proposals and additions to the D 
> language, it occurred to me that I'd like to be able to declare inside 
> my code that it requires a certain version or certain features of the D 
> language in order to work properly. For example, when I look at the 
> changelog for DMD version 2.085, I see that support for Objective-C 
> classes was added.  However, I would be hesitant to use that feature 
> until a certain amount of time has passed. This is because using it 
> would make my libraries/applications only work with a small percentage 
> of compilers in the world, those who have recently updated their 
> compiler, and the error messages people would get could make it 
> difficult to know that they just need to update their compiler for it to 
> work with my code.  Currently the only way to solve this problem is to 
> wait a certain amount of time until I feel its reasonable that enough 
> people will have updated their compiler.

Today it's possible to use the special `__VERSION__` token [1]. There's 
also `__traits(compiles)` which can be used to check if a feature is 
available. The latest version of Dub supports specifying tool chain 
requirements. That include which compiler, which version or which 
version of the frontend that is required [2].

> I think we can do better.
> 
> My current idea is to implement a list of versions and feature names.  
> Such a list could be dumped with something like:
> 
>> dmd --list-versions
> 2018_02_03 StaticForeach
> 2018_02_20 NoGCExceptions
> 2018_03_10 ObjectiveCClasses
> Implemented StaticForeach
> Implemented NamedParameters
> NotImplemented CopyConstructor
> NotImplemented ExpressionBasedContracts

Which features would be included in the list, all?

In general I think it's better to query if a specific feature is 
available or not instead of query a version or date.

[1] https://dlang.org/spec/lex.html#special-token-sequence
[2] https://dub.pm/package-format-sdl.html#toolchain-requirements

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list