First Draft: Static Single Assignment - library solution?

Nick Treleaven nick at geany.org
Wed Dec 10 21:50:14 UTC 2025


On Saturday, 6 December 2025 at 12:00:44 UTC, Nick Treleaven 
wrote:
> On Friday, 5 December 2025 at 12:20:29 UTC, monkyyy wrote:
>> I suggest asking for a template wizard to handle whatever your 
>> compiler dev usecase with a uda hack.
>
> I don't think that's possible

About the UDA - that would require some mechanism to enforce it. 
I don't think the language can do that, particularly not with 
local variables.

> - making a struct Final which acts like a type constructor. 
> E.g. you can only have one `alias this`, and it needs to rvalue 
> convert to mutable and lvalue convert to const.

Today I made a `Final` struct template. It's incomplete. What is 
there, I found issues with, and there are probably more. Initial 
ones:

1. const lvalue conversion is not implicit. When a head-const 
value is needed outside `Final!T`, it just makes an rvalue. Which 
is OK for certain types of T, but obviously larger values will do 
too much copying.

2. The operator overloads have to be conservative, e.g. opUnary 
returns an rvalue for structs because how can it tell at 
compile-time if a `ref T.opUnary` is referring to part of T's 
memory?

https://github.com/ntrel/stuff/blob/master/final.d

Perhaps someone else can do better, but this design doesn't seem 
robust enough for general use, even if it was finished.


More information about the dip.development mailing list