D Editions
Dukc
ajieskola at gmail.com
Fri May 31 11:21:30 UTC 2024
Atila Neves kirjoitti 30.5.2024 klo 21.31:
> https://github.com/atilaneves/DIPs/blob/editions/editions.md
>
> Destroy!
I suggest a different syntax. I think it should be something that would
lend itself to enabling/disabling individual features (compiler
switches) module-wise.
I'm not necessarily arguing we should make our current compiler switches
capable of being turned on or off module by module, just that if we
decided to to that, we could use the same syntax to do it. Therefore, a
decimal without any keywords is probably bad.
Version specifications are IMO a good tool for this. Just like the
proposed edition declarations, a specification is local to the module.
```D
module core.atomic;
version = D_2024;
/+ If we decided to allow it, this
syntax would work for compiler switches
(although we'd probably need a version
specification for the reverse setting
too)
+/
version = D_NoBoundsChecks;
```
Another possibility is pragmas. This is what Haskell, or more precisely
it's Glasgow compiler does to accomplish the same. I also think it's
per-module extension would be well worth putting to "prior work" section
(and investigating if you haven't already).
Another issue, that doesn't strictly affect the design of this DIP but
should be given cosideration as soon as it's used for enabling features
selectively. Suppose `@safe` is the default for edition 2026 but the
present rules apply for edition 2024. What should happen in this case?
```D
#line 1 "modulea.d"
module modulea 2024;
template T(int i)
{ // No explicit attributes.
// Note, no auto inference, because only eponymous
// functions inside a template get auto-inference.
int incr(int j) => i + j;
}
#line 1 "moduleb.d"
module moduleb 2026;
import modulea;
//Defined within edition 2024, but instantiated within edition 2026.
//@safe or @system?
//I quess @system but I want to read your opinion.
alias incr = T!(3).incr;
```
As a whole, I'm highly receptive to this DIP.
More information about the dip.ideas
mailing list