Local functions infer attributes?

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 30 06:58:51 PDT 2014


On Tuesday, 30 September 2014 at 13:47:22 UTC, John Colvin wrote:
> On Tuesday, 30 September 2014 at 07:10:08 UTC, Manu via 
> Digitalmars-d wrote:
>> On 30 September 2014 16:06, Daniel N via Digitalmars-d
>> <digitalmars-d at puremagic.com> wrote:
>>> On Monday, 29 September 2014 at 04:23:08 UTC, Timon Gehr 
>>> wrote:
>>>>
>>>> On 09/29/2014 04:43 AM, Walter Bright wrote:
>>>>>
>>>>>
>>>>> You're right that tuples in D cannot contain storage classes
>>>>
>>>>
>>>> void foo(ref int x){}
>>>> alias p=ParameterTypeTuple!foo;
>>>> pragma(msg, p); // (ref int)
>>>>
>>>> (But this does not help.)
>>>
>>>
>>> Well, only if you are sufficiently desperate. ;)
>>>
>>> struct S(alias T)
>>> {
>>>  void f(ParameterTypeTuple!T p)
>>>  {
>>>  }
>>> }
>>>
>>> S!((ref int x, int y){}) s;
>>
>> I have actually thought of that ;) ... but I tend to think 
>> that only D
>> users present on this forum are likely to make sense of that 
>> code, and
>> why.
>
> Perhaps this might help you a little:
>
> http://code.dlang.org/packages/storageclassutils
>
> sure, it's not as elegant as one would like, but it at least 
> provides some basic utility.

Also, I just wrote it in a few hours after seeing your post, so 
obviously there are plenty of improvements that could be made.


More information about the Digitalmars-d mailing list