D Editions

Timon Gehr timon.gehr at gmx.ch
Mon Jan 13 20:42:40 UTC 2025


On 12/30/24 16:49, Atila Neves wrote:
> On Saturday, 28 December 2024 at 02:03:57 UTC, Timon Gehr wrote:
>> On 12/26/24 10:55, Atila Neves wrote:
>>>>
>>>> It may not be known at library compile time what edition the user 
>>>> will be using, and there may be multiple different users on 
>>>> different editions.
>>>
>>> Right, but not all edition-specific branches will need to compile in 
>>> any one given compiler pass, right?
>>
>> Well, I think if a library wants to branch on the edition of the 
>> caller, all of those branches would need to be compiled when the 
>> library is compiled. (Think druntime.)
>>
>> Of course, the case where a library wants to branch on its own edition 
>> is separate. There, not all branches will need to compile on any given 
>> compiler invocation, though I am not sure that this is an important 
>> case (as usually every piece of code just targets a specific edition).
> 
> Ok. What do you propose we do, then? Because AFAICT none of the current 
> mechanisms will work for this.

I am not sure.

One simple idea that came to mind would be to add an `__EDITION__` 
special identifier that is evaluated in the caller's scope, similar to 
`__LINE__` and `__FILE__`, but that seems like only a partial solution.

Perhaps what would work better would be a visibility attribute that says 
"only visible from this edition/these editions".

Then you can e.g. have different declarations and alias them using 
aliases that have the correct visibility attributes.

Of course, interoperability is a concern, but that would be up to the 
library author.


More information about the dip.ideas mailing list