gracelang / language

Design of the Grace language and its libraries
GNU General Public License v2.0
6 stars 1 forks source link

both [ “a”, “b”, “c” ] and “abc” are sequences of strings... #70

Closed kjx closed 8 years ago

kjx commented 8 years ago

If Strings are also sequences of strings.

this causes a problem in that neither dynamic checking, or standard static checking, can distinguish between e.g.

list  [ “a”, “b”, “c” ]

and

list “abc”

Is this is problem?

Varargs would make list "abc" and list( "a", "b", "c" )` rather different.

apblack commented 8 years ago

I think that this was a consequence of deciding that strings are sequences of single character-strings, rather than of characters. Iterating through a String has always produced Strings. So yes, while

[ "a", "b", "c" ]

and

"abc"

are different (the second has methods like replace(_)with(_) that the first lacks), they both support iteration, and the iterators both yield the same sequence of single-character strings. So yes, the two lists constructed in the OP are identical.

With the old vararg constructors, the analogous terms would have been

list.with("a", "b", "c")

and

list.withAll "abc"

and they would also have been identical.

If, in contrast, you want a list containing the single string "abc", then with the old interface you would have written list.with "abc". With the current interface, we write list [ "abc" ]. This is exactly analogous to constructing a list containing a single number: list [ 4 ].

So, as far as I can see, everything seems to work as one would expect. What's the "issue"?

kjx commented 8 years ago

The issue is I found it confusing.

I guess the advantage of with vs withAll it is it make the creation pattern explicit.

apblack commented 8 years ago

Can we close this? I don't see any action or decision being required.