[Grace-core] collections interface for new classes
Andrew P Black
black at cs.pdx.edu
Fri Dec 11 14:44:50 PST 2015
On 10 Dec 2015, at 20:44, James Noble <kjx at ecs.vuw.ac.nz> wrote:
> OK so what are the options here?
>
> - requiring []s as sequences to be in parenthesis
> - requiring no spaces before [] as indexing (which would also work well with <> as generics)
>
> any others?
Yes — not using [ ] as an operator.
If we think that “surround” operators are important, then we should come up with general support for them. Floor, ceiling, and absolute value are the common cases that I can think of. Then [ ] for indexing could be one of them. But I don’t think that we should introduce special syntax for a single special case.
Personally, I think that with infix and prefix operators we are have enough, and that it’s not worth complicating the language to add surround operators.
Using < and > as brackets is also a bad idea. They are operators. For type parameters, we should use something like ⟦ and ⟧ or [| and |] as ASCII equivalents.
(We can’t use [[ and ]], because they now mean a sequence containing a sequence …).
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.
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.
Yes, we do require a certain pattern of indentation, although to date we have refrained from insisting that all { indents are 4 spaces,a nd all continuation lines 6 spaces. There is a benefit to this: no semicolons, which outweighs the cost. I think that there ia also broad agreement that indentation is essential for readability.
Incidentally, I believe that the “indent file” commas in the web IDE now works. I should make it available as a stand-alone program.
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailhost.cecs.pdx.edu/pipermail/grace-core/attachments/20151211/8529bab7/attachment.html>
More information about the Grace-core
mailing list