www.digitalmars.com         C & C++   DMDScript  

digitalmars.dip.ideas - explicitly temporary or permanent alias

reply monkyyy <crazymonkyyy gmail.com> writes:
Alias reassignment has various bugs, including regressions, in an 
attempt to optimize it. Sometimes I want a symbol to survive, 
other time I(by which i mean core devs) want it deleted and 
hoping a redesign to a static foreach improves compile times.

I expect it will be years before its nailed down and correct.

I suggest two new traits `__traits(delete_alias)` and 
`__traits(keep_alias)`, that explicitly keep or delete aliases a 
work arounds

```d
alias bar=Seq!();
static foreach(...){
   ...//something that triggers bugs
}
bar=__traits(delete_alias);//marks bar for deletion
```

```d
alias bar=Seq!();
bar=__traits(keep_alias);//turn off optimizations
static foreach(...){
   ...//something that triggers bugs
}
foo=bar;//foo should be correct now
```
Oct 12
parent "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
On 13/10/2024 7:47 AM, monkyyy wrote:
 Alias reassignment has various bugs, including regressions, in an 
 attempt to optimize it. Sometimes I want a symbol to survive, other time 
 I(by which i mean core devs) want it deleted and hoping a redesign to a 
 static foreach improves compile times.
 
 I expect it will be years before its nailed down and correct.
 
 I suggest two new traits `__traits(delete_alias)` and 
 `__traits(keep_alias)`, that explicitly keep or delete aliases a work 
 arounds
 
 ```d
 alias bar=Seq!();
 static foreach(...){
    ...//something that triggers bugs
 }
 bar=__traits(delete_alias);//marks bar for deletion
 ```
 
 ```d
 alias bar=Seq!();
 bar=__traits(keep_alias);//turn off optimizations
 static foreach(...){
    ...//something that triggers bugs
 }
 foo=bar;//foo should be correct now
 ```
If we were to do something like this, it would be a pragma as a hint instead. That doesn't need a DIP as it is a compiler specific instruction. Needs a bug report, with behavior of what you want done. Given its tuning related of existing behavior, you may have some success doing a PR for it.
Oct 12