[Grace-core] Minutes of Teleconference 2013-07-24

James Noble kjx at ecs.vuw.ac.nz
Tue Jul 30 09:40:57 PDT 2013


> • Blocks: we agreed that applications of blocks need to supply the same number of arguments as the block has parameters.  This is to enable the most helpful error messages.  In case of exceptional need, an "apply taking only as many arguments as you need" operation can be coded using reflection.  (This is what Smalltalk does.)  At this point, we did not see a need for having a common supertype for all blocks — instead there are separate supertypes Block0, Block1, Block2, … with zero, one, two, … arguments.

So here's a question: how do we write "for" loops now.

Michael writes code like:

>     for (1..4) do {
>         forward(length)
>         turnRight(90)
>     }

The spec has code like:
> 
>     for (1..4) do {  x -> 
>           print(i)        
>     }

and I even like the idea (from Self) of writing:

>     for (aCollectionOfStuff) do {  x, idx -> 
>           print "{idx}\t{x}"         
>     }

to print a list of indices and the values at those indices

http://docs.selflanguage.org/4.4/progguid.html#substituting-values-for-blocks


This works very nicely if blocks silently ignore unused actual arguments.
Otherwise don't we need three separate requests, perhaps something like:

>     for (1..4) repeat {
>         forward(length)
>         turnRight(90)
>     }

>     for (1..4) do {  x -> 
>           print(i)        
>     }


>    for (aCollectionOfStuff) doWithIndices {  x, idx -> 
>           print "{idx}\t{x}"         
>     }

I think it may be legitimate to cry "dialects" here - assuming dialects can change 
the methods offered on standard library objects (blocks), *if* we can overload on arity
(or we switch to Smalltalk/Self style apply()value()value() to pass in three arguments
rather than apply(3), or something)

James


More information about the Grace-core mailing list