digitalmars.dip.ideas - Imperative Templates
- monkyyy (29/29) May 08 2024 Allow saner escape hatches for state-ful templates, instead of
- Atila Neves (3/8) May 10 2024 This is a recipe for bugs wrt differences between compiling
Allow saner escape hatches for state-ful templates, instead of
compiler ~~bugs~~ fun unintended features with generally horrible
proforence, syntax and limitations
---
`__COUNTER__` a special token that increases by 1 each time its
called
```
unittest{
__COUNTER__.writeln;//0
__COUNTER__.writeln;//1
}
unittest{
__COUNTER__.writeln;//2
}
```
this is already possible with mixin and mix files
---
`__traits(oldarguments)` returns the previous template arguments
```
template foo(T...){
alias bar=__traits(oldarguments);
}
alias a=foo!int;//bar=()
alias b=foo!bool;//bar=(int)
alias c=foo!(float,double);//bar=(int,bool)
alias d=foo!();//bar=(int,bool,float,double)
```
this is already possible with my favorite compiler bug, but with
n^2 complexity
May 08 2024
On Wednesday, 8 May 2024 at 14:56:37 UTC, monkyyy wrote:Allow saner escape hatches for state-ful templates, instead of compiler ~~bugs~~ fun unintended features with generally horrible proforence, syntax and limitations --- `__COUNTER__` a special token that increases by 1 each time itsThis is a recipe for bugs wrt differences between compiling separately or not.
May 10 2024
On Friday, 10 May 2024 at 13:29:24 UTC, Atila Neves wrote:On Wednesday, 8 May 2024 at 14:56:37 UTC, monkyyy wrote:I kinda expect allot of criticism of "you shouldn't even want this" but my response will be "its already possible, people just cant read it" I believe my `mixin("__LINE__")` method to make a counter will also break with separate compilation so _such things are already in the compiler_. If this is the main criticism you have, maybe it would be possible to add a field to .o files that sets the starting point of counter, so if the counter for foo.o ended at 3 and you compile `dmd bar.d foo.o` `bar.__COUNTER__` is 4.Allow saner escape hatches for state-ful templates, instead of compiler ~~bugs~~ fun unintended features with generally horrible proforence, syntax and limitations --- `__COUNTER__` a special token that increases by 1 each time itsThis is a recipe for bugs wrt differences between compiling separately or not.
May 10 2024
On Friday, 10 May 2024 at 13:29:24 UTC, Atila Neves wrote:This is a recipe for bugs wrt differences between compiling separately or not.or option b) make it per file but id want to make suggestions on making edge cases go
May 10 2024









monkyyy <crazymonkyyy gmail.com> 