static array literal syntax request: auto x=[1,2,3]S;
Christophe Travert
travert at phare.normalesup.org
Mon Jun 11 03:06:52 PDT 2012
Jonathan M Davis , dans le message (digitalmars.D:169705), a écrit :
> auto found = find([1, 2, 3, 4, 5], 3);
No problem if the rule could be the following:
- array literals are static by default
- array literals are copied to the heap when assigned to a dynamic
array.
- the former rule applies even if the array literal is assigned to a
dynamic array via a function call, like it is the case in this example.
- if a function can take both static and dynamic array as parameter,
the static version takes precedence (it is always possible to call the
dynamic version via slicing, at your own risk since the array is no
longer valid at the end of the function call, or, much more wisely, by
explicitely using the .dup property).
More information about the Digitalmars-d
mailing list