Associative Arrays with elements having function type?
Nicholas Wilson
iamthewilsonator at hotmail.com
Wed Nov 12 01:26:55 UTC 2025
On Tuesday, 11 November 2025 at 17:58:33 UTC, Quirin Schroll
wrote:
> On Monday, 3 November 2025 at 22:29:13 UTC, H. S. Teoh wrote:
>> On Mon, Nov 03, 2025 at 09:29:47PM +0000, kdevel via
>> Digitalmars-d wrote:
>>> Yesterday I read
>>>
>>> 3. Neither the KeyTypes nor the element types of an
>>> associative array
>>> can be function types or void.
>>>
>>> in <https://dlang.org/spec/hash-map.html>. Does the program
>>> below work only accidentally?
>> [...]
>>
>> I think this is a mistake in the spec. There is no reason why
>> the value type of an AA can't be a function (pointer) or
>> delegate. I use this quite a lot.
>
> There’s a big difference between a function type and a function
> pointer type. (I don’t know why D even has function types.
> Borderline useless.)
For internal compiler organisation reasons, for mangling, and for
C++ interoperability.
Very useful, just indirectly.
More information about the Digitalmars-d
mailing list