Array literals' default type

bearophile bearophileHUGS at lycos.com
Fri Oct 9 16:23:08 PDT 2009


Andrei Alexandrescu:

> Relax. It's a condition known as literalitis. :o)

While I guess the opposite illness is literalphobia :-)


> Literals only have you write [ a, b, c ] instead of toArray(a, b, c). I 
> wouldn't see it a big deal one way or another, but the issue is that the 
> former is a one-time decision that pretty much can't be changed, whereas 
> toArray can benefit of the hindsight of experience.

Literals for basic things are a good thing, handy, short, easy to think about, like icons; for things like strings, arrays, associative arrays, sets, bignums, complex numbers, and few more. Such things are common or very common in programs, and simple enough that a good design can be found and used.

When you design a language you have to balance the generality with the specificity. Both extrema have disadvantages. Your designs are usually good, but often they risk a little overgeneralisation.

Bye,
bearophile



More information about the Digitalmars-d mailing list