www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - dip: __HERE__ special token

reply monkyyy <crazymonkyyy gmail.com> writes:
```
int ignored;
int referenced;
void main(){
     alias foo=referenced;
     struct bar{}
     alias faz=sometemplate!int;
     alias firstcopy=__HERE__;//foo,bar,faz
     int baz;
     alias secondcopy=__HERE__;//foo,bar,faz,firstcopy,baz
}
```

https://github.com/crazymonkyyy/DIPs/blob/master/DIPs/1NNN-MKY.md

A special token for convenience while meta programming
Apr 10 2022
parent reply Alexandru Ermicioi <alexandru.ermicioi gmail.com> writes:
On Sunday, 10 April 2022 at 19:10:31 UTC, monkyyy wrote:
 ```
 int ignored;
 int referenced;
 void main(){
     alias foo=referenced;
     struct bar{}
     alias faz=sometemplate!int;
     alias firstcopy=__HERE__;//foo,bar,faz
     int baz;
     alias secondcopy=__HERE__;//foo,bar,faz,firstcopy,baz
 }
 ```

 https://github.com/crazymonkyyy/DIPs/blob/master/DIPs/1NNN-MKY.md

 A special token for convenience while meta programming
Tuples in D right now autoexpand, making the expectation in secondcopy wrong. The result would be just, foo,bar,faz,foo,bar,faz,baz. Still, whats the use case of this functionality?
Apr 10 2022
parent reply monkyyy <crazymonkyyy gmail.com> writes:
On Sunday, 10 April 2022 at 21:50:59 UTC, Alexandru Ermicioi 
wrote:
 Still, whats the use case of this functionality?
Mostly I want a cleaner way to get symbols for when I revisit https://github.com/crazymonkyyy/comfysettings and I do think defining a list of things to then turn around and do something repetitive with them is common
Apr 11 2022
parent reply Alexandru Ermicioi <alexandru.ermicioi gmail.com> writes:
On Monday, 11 April 2022 at 16:36:02 UTC, monkyyy wrote:
 On Sunday, 10 April 2022 at 21:50:59 UTC, Alexandru Ermicioi 
 wrote:
 Still, whats the use case of this functionality?
Mostly I want a cleaner way to get symbols for when I revisit https://github.com/crazymonkyyy/comfysettings
You could group your fields in a struct, and use with expression, btw.
 and I do think defining a list of things to then turn around 
 and do something repetitive with them is common
Regarding the dip. You might better change __here__ to something more meaningful. People not knowing what __here__ does will inadvertently ask: here what? while reading this token.
Apr 11 2022
next sibling parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 4/11/22 15:48, Alexandru Ermicioi wrote:

 People not knowing what __here__ does will inadvertently
 ask: here what?
Not me! I know it means heredoc: :) https://dlang.org/spec/lex.html#delimited_strings Ali
Apr 11 2022
prev sibling parent monkyyy <crazymonkyyy gmail.com> writes:
On Monday, 11 April 2022 at 22:48:31 UTC, Alexandru Ermicioi 
wrote:
 You could group your fields in a struct, and use with 
 expression, btw.
Suppose your debugging a block of code with debug printer from the dip examples ```d int foo; float bar; bool faz; alias dp=debugprinter!(); foreach(...){...} ``` to disable faz from being printed you would edit this code to ```d int foo; float bar; alias dp=debugprinter!(); bool faz; foreach(...){...} ``` if your organizing your variables in a struct you'd have to hunt down your usage of faz. The explicit purpose is to NOT require such structure
Apr 12 2022