Carl Mäsak wrote:
Darren (>):
 Bit
 Blob
 Set
 Bag
 Mapping

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?

Why is the latter method insufficient for your needs?

I consider these types to be just as fundamental as the others I mentioned, some more so, and it should be possible to define their values in a manner that is just as clean and terse.

In my mind, having to gain one of the above values by converting to it from some other type using a function, seems as stupid as having to write a Str literal and use a strtoint function to get an Int value, when it makes more sense to just have special syntax for an Int in the first place.

Besides-which, I don't even see any converter functions defined to derive these from other types.

At the very least I want to know the tersest and cleanest thing I can write, for each of the above 5 types, that will give me a value of that type.

As one suggestion for a Blob syntax if they don't already exist, is something derived from both the syntaxes for character strings and numbers:

  0b'1100101110' # 1 bit represented per sourcecode char
  0o'62'         # 3 bits represented per sourcecode char
  0x'50B7168E'    # 4 bits represented per sourcecode char

Also, the catenation operator "~" and friends should also be defined for Blob.

I'm not as sure what to suggest for the other 4 types, though I suppose in a pinch they could look less special, like "Set{...}", "Bag{...}", "Mapping{...}" with the contents of the braces like what you'd get declaring a Hash literal.

The point is, I'd like some sort of statement (which can be changed later) from @Larry in the Synopsis so that I know how to write Perl 6 code that declares (and addresses elements of where applicable) literals of the above types, and also so that implementations like Rakudo have guidance to make them work.

Note, in general I like the distinctive syntax, say, of having [] for ordered collections and {} for unordered collections, as is already the case for Array and Hash, for both value declaration and element addressing.

-- Darren Duncan

Reply via email to