Re: Generating unique identifiers at compile time

2022-06-09 Thread user1234 via Digitalmars-d-learn

On Thursday, 9 June 2022 at 21:20:27 UTC, JG wrote:

Hi,

As an experiment I have implemented the following kind of 
pattern matching

(by parsing the part of the string before '=').

```d
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:


```d
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?


No, for now there if there are other ways they are as hacky as 
yours.


The compiler usually uses a global counter to generate 
temporaries.
There's [been attempts] to expose it, exactly so that users can 
generate unique names, but that did not found its path in the 
compiler.


[been attempts]: https://github.com/dlang/dmd/pull/10131


Generating unique identifiers at compile time

2022-06-09 Thread JG via Digitalmars-d-learn

Hi,

As an experiment I have implemented the following kind of pattern 
matching

(by parsing the part of the string before '=').

```d
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:


```d
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?







Re: What happened to Circular Studio?

2022-06-09 Thread evilrat via Digitalmars-d-learn
On Monday, 6 June 2022 at 21:07:58 UTC, Steven Schveighoffer 
wrote:

On 6/6/22 3:46 PM, Jack wrote:
I just found out a game using D to develop games but later I 
see the last updates on the github, web site, twitter etc is 
from 2015. Does anyone knows what happend to the company?


It appears to be just a playground for a bunch of friends at 
RIT, I'm not sure how much of a "company" this was.


But, there is activity in the github issues list, circa 
November 2020: 
https://github.com/Circular-Studios/Dash/issues/249


But who knows, probably just fizzled out. I admit, I never 
heard of them.


-Steve


Their engine was unfortunate enough to land before the great 
language update in 2015-2016, basically updating it to work with 
current D well be such a PITA that it is easier to rewrite from 
scratch, I did tried to update it but eventually abandoned it 
because there is tons of dependencies from that era that was 
abandoned as well.


It has some nice ideas like Unity-like class registration and 
metadata using CTFE but that's basically it...
They even have minor issues in shaders like right-handed math 
mixed with left-handed math resulting in broken shadows and more 
issues.