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

Kim Bruce kim at cs.pomona.edu
Tue Jul 30 10:10:21 PDT 2013


They are three different things, so shouldn't they have three different methods?  Seems logical to me!  Parameters are hard for students under any circumstances.  Having parameters that sometimes are there and sometimes not makes it even trickier.

There should be:
repeat(n)times(zeroaryblock)
for(vals)do(unaryBlock)
withValIndex(vals)do(binaryBlock)

(I'd like a better name for the last, but the first two are pretty intuitive)

Kim



On Jul 30, 2013, at 9:40 AM, James Noble <kjx at ecs.vuw.ac.nz> wrote:

>> • 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
> _______________________________________________
> Grace-core mailing list
> Grace-core at cecs.pdx.edu
> https://mailhost.cecs.pdx.edu/mailman/listinfo/grace-core




More information about the Grace-core mailing list