shared and getParameterStorageClasses bug?

Jean-Louis Leroy jl at leroy.nyc
Sun Aug 23 14:11:21 UTC 2020


On Sunday, 23 August 2020 at 13:44:30 UTC, Jean-Louis Leroy wrote:
> On Sunday, 23 August 2020 at 06:42:02 UTC, Petar Kirov 
> [ZombineDev] wrote:
>
>> [...]
>
> Thanks. Then my follow-up question is: how do I retrieve the 
> parameter type constructors? Without resorting on scanning the 
> stringified parameter like here:
>
> enum isSharedParameter(alias fun, uint param) =
>   Parameters!fun[param..param+1].stringof.indexOf("shared") != 
> -1;
>
> (of course this is not robust: it would give false positives 
> with types that contain the substring "shared").
>
> My actual goal is to extract them in the same fashion as the 
> storage classes, e.g.:
>
> void foo(lazy const shared Object);
> static assert(parameterTypeConstructors!foo == tuple("const", 
> "shared"));
>
> Do I really have to parse a string like "(lazy 
> shared(const(Object)))"? And, how reliable would this solution 
> be?

OK since the `shared` has migrated to the type, isSharedParameter 
can be written like this:

enum isSharedParameter(alias fun, uint param) =
   is(Parameters!fun[param] == SharedOf!(Parameters!fun[param]));



More information about the Digitalmars-d mailing list