On Sun, 13 Dec 2015, Allin Cottrell wrote:
Before I document this let me float an idea. We could rename
mkarray() as
just array(), but preserve the existing functionality of array() -- that is,
to create an array of specified size with each member initialized to an
appropriate "empty" value -- in this way: if the function is given a single,
scalar argument it acts as array() currently acts, otherwise it acts as
mkarray(). [Note that we don't accept scalars as arguments to mkarray(); you
can't have an array of scalars as such.]
Question(s): is this too tricksy? And if it is too tricksy and we want two
separate functions, is the name "mkarray" alright for the new one or can
anyone think of a better name?
No, it isn't. In fact, I find it brilliant. array("3") would be
different from array({3}) which would be, in turn, different from
array(3) (where the last expression would need an explicit type
declaration, eg, "matrices"). I'm all for it.
The only problems (of clarity, mainly) would arise in certain contexts,
due to the subtleties of implicit type conversion. For example:
<hansl>
foo = array(3 + I(1))
list X = a b c
loop foreach i X
zoo_$i = array($i)
endloop
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------