[Grace-core] minor language issues

Andrew P Black andrew.p.black at gmail.com
Wed May 20 14:59:53 PDT 2015


On 18 May 2015, at 17:30 , Marco Servetto <marco.servetto at gmail.com> wrote:

> On 19 May 2015 at 12:18, Andrew P Black <andrew.p.black at gmail.com> wrote:
>> On the whole,  variable arity methods seem better than the alternative,
>> which is to privilege one kind of collection by giving it a special syntax.
> 
> 
> Ok, so... what kind of collection is used when the method body tries
> to read that parameter?

We tell the programmer that the interface is defined by the Sequence type.  So yes, in a sense we are privileging that kind of collection.  But the implementation need not actually reify it.   If set, for example, is implemented by a built-in library that has low-level access to the constructor arguments, then the set could be built directly without the need to build a sequence along the way.   In general, because the collection of arguments is built by the invoked method, rather than by the requester,  a reasonable compiler could do some escape analysis and avoid building any object in most cases.

Variable arity methods also make the syntax seen by the requester more uniform.  The requestor writes set.with(4, 5, 6), list.with(4, 5, 6) and sequence.with(4, 5, 6) rather than set.with[4, 5, 6], list.with[4, 5, 6] and [4, 5, 6].  Although, as you point out, on the implementers side Sequence is still privileged.

I'm more concerned with uniformity for the use than for the implementor.  And although implementation efficiency is not our primary concern, it's nice to pick the alternative that keeps more options open for the implementer.
	
	Andrew

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailhost.cecs.pdx.edu/pipermail/grace-core/attachments/20150520/892a76ac/attachment.html>


More information about the Grace-core mailing list