Hi,
As an experiment I have implemented the following kind of pattern matching
(by parsing the part of the string before '=').
struct S {
int x;
int y;
}
struct T {
int w;
S s;
}
void main()
{
mixin(matchAssign(q{auto T(first,S(second,third)) = T(1,S(2,3));}));
first.writeln; // 1
second.writeln; // 2
third.writeln; // 3
}
In doing so I wanted to produce unique identifiers (something like gensym in racket.) I did this in a very hacky way:
auto hopefullyUniqueName(size_t n, size_t line=__LINE__) {
return format!"____________________________var___________________________%s%s"(n,line);
}
where I pass in the hash of the right hand side in the assignment in place of n.
Is there some way to ask the compiler for a unique name or a better way of achieving this?