Moritz Lenz wrote:
Darren Duncan wrote:
But some significant ones I don't know and really want to know:
I guess that Mapping is analog to the List/Seq case:
Sure, but given how Pair literals work, how would you know whether the above (if
you meant to surround it in parenthesis) is a List|Seq of 2 elements that are
Pair, or a Mapping of 2 keys and 2 values? So some other delimiter than plain
parenthesis is needed I would think.
How does one write anonymous value literals of those types? And I mean
directly, not by writing a literal of some other type and using a conversion
function to derive the above?
In that case, what is the syntax for what you put in the "..."? Is it just a
comma-delimited list like when you spell out arguments for an arbitrary routine
call with positional or named parameters?
Also, if that was the default solution for built-in collection types with no
special syntax, I would expect for consistency that you could also say eg
Hash.new(...) or Array.new(...) or Seq.new(...) etc; if that's the case, then
this situation looks better than otherwise.
The above is my main question, but also I wonder about how to make an anonymous
literal of a KeyHash|KeySet|KeyBag.
I think that's (from a language user's point) the "wrong" question.
These types are not designed to be very much visible for the user, but
more like helpers. (Please correct me if I'm wrong here).
Fair enough. Actually come to think of it I think those 3 are just "subtype Foo
of Hash where ..." anyway and and they don't need special syntax.
Regarding Blob, that's not a collection type and its a fundamental type and it
still needs special syntax; I did suggest one in my previous message.
As for the collection types, well Foo.new(...) could work if necessary, though
terser syntax would be nice to have.
What I would like is to be able to write value literals that involve arbitrarily
complex nested structures where all the elements at every level are immutable
types; having Seq|List is a start, but good Set|Mapping|Bag syntax is needed too.
Thank you. -- Darren Duncan