# Re: Bag / Set ideas - making them substitutable for Arrays makes them more useful

```Jonathan Lang (>):
> 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)
>
> AFAIK, this would cause no conflicts with existing code.
>
> Or maybe these should be reversed:
>
>    [[1, 1, 2, 3]] # a Set containing 1, 2, and 3
>    {{1, 1, 2, 3}} # a Bag containing two 1s, a 2, and a 3
>    {{1 => 2, 2 => 1, 3 => 1}} # another way of defining the same Bag,
> with explicit counts.
>
> OTOH, perhaps the outermost character should always be a square brace,
> to indicate that it operates primarily like a list; while the
> innermost character should be either a square brace or a curly brace,
> to hint at thye kind of syntax that you might find inside:
>
>    [[1, 1, 2, 3]] # a Set containing 1, 2, and 3
>    [{1, 1, 2, 3}] # a Bag containing two 1s, a 2, and a 3
>    [{1 => 2, 2 => 1, 3 => 1}] # another way of defining the same Bag,
> with explicit counts.
>
> Yeah; I could see that.  The only catch is that it might cause
> problems with existing code that nests square or curly braces inside
> of square braces:
>
>    [[1, 2, 3], [4, 5, 6], [7, 8, 9]] # fail; would try to create Set
> from "1, 2, 3], [4, 5, 6], [7, 8, 9"
>    [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] # creates 3-by-3 array
>
> ...so maybe not.
>
> It should never be more than two characters on either side; and
> there's some benefit to using square or curly braces as one of them,
> to hint at proper syntax within.  Hmm... how about:
>
>    |[1, 2, 3]| # Set literal
>    |[1=>true, 2=>true, 3=>true]| # technically possible; but why do it?
>    |{1, 1, 2, 3}| # Bag literal
>    |{1=>2, 2=>1, 3=>1}| # counted Bag literal```
```
After skimming all those suggestions, I have yet another proposal:
let's not add anything, creating marginal gain with lots of extra
syntax.

> 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.

+1. Let's leave it at that.

// Carl
```