[Grace-core] minor language issues

Kim Bruce kbbruce47 at gmail.com
Tue May 26 13:54:08 PDT 2015


I also suggested the fairly simple solution to the null var args problem as
having a varargs parameter mean one or more rather than zero or more
occurrences.  It just means you have to define a new method for the null
case if needed.

E.g., the following two methods give you the null and non-null cases for
printing values.
method print(*a) {...}
method printNewLine {...}

In my opinion, varargs are sufficiently rare (particularly for students
writing code) that this extra definition is not a major pain.  In fact, I
believe Andrew used this for the constructors for the collection classes.
 (I believe he has also argued that one should write the version of the
methods taking the list/sequence before writing the vararg version.  Hence
there is only a tiny amount of extra work here.)

To me, it seems like a fairly simple and straightforward solution to the
varargs problem.

On Tue, May 26, 2015 at 1:02 AM James Noble <kjx at ecs.vuw.ac.nz> wrote:

> > Minigrace does not do this.
>
> well I thought something did at some time;
> (I probably didn’t like it then).
>
> >>       we could give up on indexing (which many of you have reached
> already) which resolves this...
> > Or you can use parentheses to pass arbitrary expressions as arguments,
> > which seems to be the missing case nobody is talking about...
>
> so that would be
> list.empty
> list.with([])
> list.with([1, 2, 3])
> list.with([1, 2, 3], [4, 5, 6])
>
>
> hmm.  In many ways, I guess typing “([“ and “])” for list arguments is no
> worse than other options (e.g. [[ ]])
>
> list.empty
> list.with [[]]
> list.with [[ 1, 2, 3 ]]
> list.with([[1, 2, 3 ]], [[ 4, 5, 6 ]])
>
>
> part of me says: [] reserved for indexing, other bracket ops for literals,
> so they are syntactically distinct.
>
>
> I guess we could try to ask questions of corpora like: how many different
> indexing ops would objects need?
> how many different matchfix brackets would dialects need?
>
> I suppose Smalltalk can tell us how many array literals there are vs calls
> to at: and at: put:
>
> James
> _______________________________________________
> Grace-core mailing list
> Grace-core at cecs.pdx.edu
> https://mailhost.cecs.pdx.edu/mailman/listinfo/grace-core
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailhost.cecs.pdx.edu/pipermail/grace-core/attachments/20150526/b5de28f8/attachment.html>


More information about the Grace-core mailing list