Open GoogleCodeExporter opened 9 years ago
I'm not really sure what you mean by this, can you give a more detailed example?
Original comment by mind...@gmail.com
on 3 Oct 2010 at 2:39
The shorthand would then be:
s:="this is a constant string";
a:=(1,2,3);
d:={"key1": value1, ...};
Original comment by Conrad.S...@gmail.com
on 3 Oct 2010 at 5:26
s := "this is a constant string" already works (type of 's' would be
StaticString, a subclass of String).
For the sequence and mapping types, the plan is to allow:
# create an immutable sequence
s := [1, 2, 3];
# initialize a sequence type
List l = ['first', 'second', 'third'];
# create an immutable map
m := [ 'key1': 'value 1', 'key2': 'value 2' ];
# initialize a map type
RBTree m = [ 'key1': 'value1', 'key2': 'value2' ];
I would very much prefer curly-braces for map initializers, but unfortunately
the curlies are already heavily overloaded. In particular, this syntax would
be ambiguous with the use of keyword arguments in a constructor:
SomeClass a = { parm1: 'parm 1', parm2: 100 };
Original comment by mind...@gmail.com
on 3 Oct 2010 at 8:33
Could there maybe be a 'decorator' to show that the sequence or map is not
immutable?
Original comment by Conrad.S...@gmail.com
on 3 Oct 2010 at 9:33
I'm not entirely sure that the sequences and maps need to be immutable - I
originally thought that this might be useful as an optimization for sequences.
The C-like syntax will definitely create non-immutable objects (the second and
fourth examples above are normal, mutable List and RBTree instances)
And in any case, you should be able get the language to do anything you want
with annotations (coming up in 0.3). You could, for example define an
annotation that works like this:
s := @mut [1, 2, 3]; # create a mutable array
Original comment by mind...@gmail.com
on 4 Oct 2010 at 10:55
Accepting this for the implementation of the forms described.
Original comment by mind...@gmail.com
on 5 Oct 2010 at 4:42
This is now partially implemented in revision ac379d4f41ee
Specifically, sequences can be defined in initialization and in expressions
when qualified by the container type.
What remains to be done:
- support this for maps
- integrate it with type inferencing
- allow registration of a default sequence and map generic to be used when the
type cannot be otherwise inferred.
Original comment by mind...@gmail.com
on 29 Mar 2011 at 11:34
Original issue reported on code.google.com by
Conrad.S...@gmail.com
on 3 Oct 2010 at 1:55