Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
July 11, 2015 Function pointer array slice? | ||||
---|---|---|---|---|
| ||||
So simple syntax question, how do I make an array slice of function pointers? I just have no idea where to put the [] on something like void function() nothrow pure @nogc @safe arrayName; Or should I just alias it and make an array of the alias? alias f = void function() nothrow pure @nogc @safe; f[] arrayName; |
July 11, 2015 Re: Function pointer array slice? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tofu Ninja | On Saturday, 11 July 2015 at 09:30:43 UTC, Tofu Ninja wrote:
> So simple syntax question, how do I make an array slice of function pointers?
>
> I just have no idea where to put the [] on something like
>
> void function() nothrow pure @nogc @safe arrayName;
>
> Or should I just alias it and make an array of the alias?
>
> alias f = void function() nothrow pure @nogc @safe;
> f[] arrayName;
Alias is the correct way IMO.
|
July 11, 2015 Re: Function pointer array slice? | ||||
---|---|---|---|---|
| ||||
Posted in reply to tcak Attachments: | On Sat, 11 Jul 2015 09:54:40 +0000, tcak wrote:
> On Saturday, 11 July 2015 at 09:30:43 UTC, Tofu Ninja wrote:
>> So simple syntax question, how do I make an array slice of function pointers?
>>
>> I just have no idea where to put the [] on something like
>>
>> void function() nothrow pure @nogc @safe arrayName;
>>
>> Or should I just alias it and make an array of the alias?
>>
>> alias f = void function() nothrow pure @nogc @safe;
>> f[] arrayName;
>
> Alias is the correct way IMO.
yet
void function() nothrow pure @nogc @safe [2]arrayName;
is perfectly fine too.
|
July 11, 2015 Re: Function pointer array slice? | ||||
---|---|---|---|---|
| ||||
Posted in reply to ketmar | On Saturday, 11 July 2015 at 10:54:45 UTC, ketmar wrote:
> On Sat, 11 Jul 2015 09:54:40 +0000, tcak wrote:
>
>> On Saturday, 11 July 2015 at 09:30:43 UTC, Tofu Ninja wrote:
>>> So simple syntax question, how do I make an array slice of function pointers?
>>>
>>> I just have no idea where to put the [] on something like
>>>
>>> void function() nothrow pure @nogc @safe arrayName;
>>>
>>> Or should I just alias it and make an array of the alias?
>>>
>>> alias f = void function() nothrow pure @nogc @safe;
>>> f[] arrayName;
>>
>> Alias is the correct way IMO.
>
> yet
>
> void function() nothrow pure @nogc @safe [2]arrayName;
>
> is perfectly fine too.
Ahh, guess that makes sense, I kept trying to put the [] over near function()... looks weird as hell though. I really wish you could put types in parens, I feel like things like this would make way more sense if you could write
(void function() nothrow pure @nogc @safe)[] arrayName;
Reading it, that makes wayyy more sense to me, to bad I can't write this...
|
July 12, 2015 Re: Function pointer array slice? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tofu Ninja Attachments: | On Sat, 11 Jul 2015 11:37:03 +0000, Tofu Ninja wrote: >> void function() nothrow pure @nogc @safe [2]arrayName; >> >> is perfectly fine too. > > Ahh, guess that makes sense, I kept trying to put the [] over near > function()... attributes are the parts of the type. and the rule is really simple: put "[]" array declaration immediately left of the array name. ;-) > looks weird as hell though. I really wish you could put > types in parens, I feel like things like this would make way more sense > if you could write > > (void function() nothrow pure @nogc @safe)[] arrayName; > > Reading it, that makes wayyy more sense to me, to bad I can't write this... i agree, this is somewhat easier to read. but it requires grammar changes, i believe, and dunno what consequences that may have. yet it may worth filling a ER. |
Copyright © 1999-2021 by the D Language Foundation