[Grace-core] How many method application brackets does one language need?

Michael Homer mwh at ecs.vuw.ac.nz
Mon Mar 7 17:41:03 PST 2016


With the recent introduction of [ ... ] iterables, there are now two
different kinds of method application brackets (in effect).¹

When *declaring* a method, you only use (), and you specify the other
kind using a type annotation.

When *calling* a method, both kinds are in use. The difference between
the two is that one kind is used for a method that takes arbitrarily
many arguments, while the other is used for methods that accept a
fixed number. The caller of the method must know this fact about the
method implementation, even though in the concrete case they are
always passing a fixed number of arguments.

If you use the wrong kind of bracket, you will get a type error.

Is it necessary to impose this complexity onto the novice user?
-Michael

¹ Of course, you *can* use [] outside of method calls, as in `def x =
[1,2,3]`, but it doesn't seem very useful. At one point I thought I
saw that [] were not intended for end-user use at all, but only for
internals of library implementation, but they seem to be appearing in
user-facing interfaces such as `list [1,2,3]` now. It always seemed
odd that something nobody was going to use was the shortest object to
create, so that seems like a logical development. In this message I'm
considering their use as direct arguments to a method call only, where
a variably-sized list of values is passed to the method.

For clarity, an example of both styles of call is:
    list ( 1, 2, 3 )
    list [ 1, 2, 3 ]

And the declaration:
    method list(x, y, z) { ... }
    method list(items : Iterable<Number>) { ... }



More information about the Grace-core mailing list