Associative arrays
Ola Fosheim Grostad
ola.fosheim.grostad at gmail.com
Tue May 18 09:41:06 UTC 2021
On Tuesday, 18 May 2021 at 09:14:46 UTC, Chris Piker wrote:
> On Tuesday, 18 May 2021 at 08:22:56 UTC, Ola Fosheim Grostad
> wrote:
>> The main reason is that D needs better metaprogramming.
>
> That's an interesting take.
>
> So far, with only a month's usage of D I'm seeing so much
> meta-programming capability that it actually worries me a bit.
> With string mixins and so many other meta programming features
> around I'm starting to think that reading other people's D code
> is going to be quite difficult, similar to perl.
>
>> Golden design rule: never add language features that can be
>> done as library constructs, ever.
>
> This sounds like a reasonable position. Imagine for a second
> that AAs were implemented as a library. What would the library
> equivalent of this:
>
> ```d
> long[string] aea = ["foo": 5, "bar": 10, "baz": 2000 ];
> ```
>
> look like?
It could look the same, but long[string] would now be a
shorthand for std.xyz.Map!(long,string) or something like that
instead of a special case.
More information about the Digitalmars-d
mailing list