shared and getParameterStorageClasses bug?

Petar Petar
Tue Aug 25 13:45:36 UTC 2020

On Tuesday, 25 August 2020 at 12:52:14 UTC, Jean-Louis Leroy 
> On Tuesday, 25 August 2020 at 07:16:39 UTC, Petar Kirov 
> [ZombineDev] wrote:
>> Interesting, so essentially, you need a good solution for your 
>> refractParameter function, right? I'll try to check the code 
>> in more detail later and think about it.
> Actually it already works as is:
> void original(lazy const Object);
> enum edited =
>   refract!(original, "original")
>   .withName("copy")
>   .withParametersAt(0, Parameter("foo", "int"));
> mixin(edited.mixture);
> void expected(int, lazy const Object);
> static assert(is(typeof(&copy) == typeof(&expected)));
> The generated mixin is:
> pragma(msg, edited.mixture);
> // @system bolts.experimental.refraction.ReturnType!(original)
> // copy(int foo, lazy 
> bolts.experimental.refraction.Parameters!(original)[0] _0);
> (In this case, Parameters!(original)[0..1] (note the ..) would 
> have worked as well - and it would have looker better too. I'll 
> implement that soon.)
> Let's look at the function types:
> pragma(msg, typeof(&original).stringof); // void function(lazy 
> const(Object))
> pragma(msg, typeof(&copy).stringof);     // void function(int 
> foo, lazy const(Object) _0) @system


> It looks like it is impossible to tell the difference between 
> 'const object' and 'const(Object)' - the substitution happens 
> too early. So I guess it doesn't matter...

Yes, `Q T` and `Q(T)` is exactly the same type (for Q ∈ { const, 
immutable, shared, inout } ), so you shouldn't try to 
differentiate between the two. (And `Q(T)` is the canonical 

BTW, 2-3 years ago I played with a similar task (meta programming 
utility library), and one difference in the approach I took was 
to avoid thick abstractions. In some cases, this works well, 
though since I didn't have use cases involving heavy function 
type processing recently I didn't push much in that direction.

You can find some of the code here:

More information about the Digitalmars-d mailing list