Darren Duncan wrote:
> Jon Lang wrote:
>>
>> That saves a singlr character over Bag( ... ) and Set( ... ),
>> respectively (or three characters, if you find decent unicode bracket
>> choices).  It still wouldn't be a big enough deal to me to bother with
>> it.
>>
>> As well, my first impression upon seeing [! ... !] was to think
>> "you're negating everything inside?"  That said, I could get behind
>> doubled brackets:
>>
>>    [[1, 2, 3]] # same as Bag(1, 2, 3)
>>    {{1, 2, 3}} # same as Set(1, 2, 3)
>
> <snip>
>
> I prefer to have the mnemonic that {} means unordered and that [] means
> ordered, so please stick to [] meaning arrays or ordered collections, an {}
> meaning unordered collections, so set and bag syntax should be based around
> {} if either.
>
> This said, I specifically think that a simple pair of curly braces is the
> best way to mark a Set.
>
> So:
>
>  {1,2,3}  # a Set of those 3 elements
>
> ... and this is also how it is done in maths I believe (and in Muldis D).
>
> In fact, I strongly support this assuming that all disambiguation eg with
> hashes can be specified.

That would be great.

>  {a=>1,b=>2}  # a Hash of 2 pairs
>
>  {:a<1>, :a<2>}  # we'll have to pick a meaning

My preference would be for this to be a Set that contains two items in
it, both of which are pairs.  IIRC, there's already behavior along
these lines when it comes to pairs.

>  {}  # we'll have to pick a meaning (Muldis D makes it a Set; %:{} is its
> Hash)

Is there any difference between an empty Set and an empty Hash?  If
so, is one more general than the other?  Just as importantly, what
does {} do right now?

>  {;}  # an anonymous sub or something
>
>  {a=>1}  # Hash
>
>  {1}  # Set
>
>  {1;}  # anonymous sub or something

Sets built from multi-dimensional arrays migt be a problem:

    {1, 2, 3: 4, 5, 6}

> But keep that simple an let nesting work normally, so:
>
>  {{1}}  # a Set of 1 element that is a Set of 1 element
>
>  {{a=>1}}  # a Set with 1 Hash element
>
>  {[1]}  # a Set with 1 Array element
>
>  [{1}]  # an Array with 1 Set element
>
> In certain cases, we can always still fall back to this:
>
>  Set()  # empty Set
>
>  Hash()  # empty Hash
>
>  Set(:a<1>)  # if that's what we wanted
>
> As for bags, well I think that is where we could get fancier.
>
> But *no* doubling up, as we don't want to interfere with nesting.
>
> Instead, it is common in maths to associate a "+" with set syntax to refer
> to bags instead.
>
> So, does Perl already ascribe a meaning to putting a + with various
> bracketing characters, such as this:
>
>  +{1,2,2,5}  # a Bag of 4 elements with 2 duplicates
>
>  +{}  # an empty Bag, unless that already means something
>
> So would the above try to cast the collection as a number, or take the count
> of its elements, or can we use something like that?

I'd expect +{...} to count the elements.



-- 
Jonathan "Dataweaver" Lang

Reply via email to