[Grace-core] collections interface for new classes
James Noble
kjx at ecs.vuw.ac.nz
Fri Dec 11 19:55:21 PST 2015
> They are operators. For type parameters, we should use something like ⟦ and ⟧ or [| and |] as ASCII equivalents.
people have to be able to copy-type Grace by reading code and looking at their keyboards.
I don’t what to change that principle now.
We can have [| |] either for type params or literals (or both) if we want to, if we don’t think it’s too ugly.
def suits : Sequence[String] = [ “hearts”, “clubs”, “diamonds”, “spades” ]
def suits : Sequence[|String|] = [ “hearts”, “clubs”, “diamonds”, “spades” ]
def suits : Sequence[String] = [| “hearts”, “clubs”, “diamonds”, “spades” |]
def suits : Sequence<String> = [ “hearts”, “clubs”, “diamonds”, “spades” ]
(note that if [ ] builds something like a literalSequece<Dynamic> then this won't do what you expect. at all)
and if neither Kernan nor (a)mg check types on arguments, perhaps this is all moot anyway.
> (We can’t use [[ and ]], because they now mean a sequence containing a sequence …)
sure we can, given that we already have “>” and “>>” as separate operators…
> Neither I nor Kim use [ ] with the meaning of `.at` when teaching. The notation a[i] := expr is actually misleading, when compared to a.at (i) put (expr). The latter is clearly an operation on the object a. The former makes a[i] look like a variable.
well that’s the point. after all, "a:= expr” makes a look like a variable :=)
I noted somewhere in passing that some early Smalltalks allowed the equivalent of a.at(i) := expr.
I think we can do this in Grace if we want to.
(the actual Smtalltalk syntax was a ◦ i ← expr and I had to open my character viewer to enter that!)
> There will always be matters of taste in spacing. Do you put spaces in requests like `at (i) put (expr)`? How many? Where? Do we want to legislate this, or leave it up to students to develop their own sense of style.
we can decide what we want to do.
> Yes, we do require a certain pattern of indentation, although to date we have refrained from insisting that all { indents are 4 spaces,
we did say > 1 space at Pomona…
J
More information about the Grace-core
mailing list