Thread overview
dip: __HERE__ special token
Apr 10, 2022
monkyyy
Apr 10, 2022
Alexandru Ermicioi
Apr 11, 2022
monkyyy
Apr 11, 2022
Alexandru Ermicioi
Apr 11, 2022
Ali Çehreli
Apr 12, 2022
monkyyy
April 10, 2022
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

April 10, 2022

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?

April 11, 2022

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

April 11, 2022
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.

April 11, 2022
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

April 12, 2022
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