[Grace-core] An error or ???

Timothy Jones tim at ecs.vuw.ac.nz
Wed Jun 25 17:01:35 PDT 2014


On 25/06, Kim Bruce wrote:
> The following program is (I believe) technically wrong.
> 
> for(1..3)do{
>    print(5)
> }

Yes, the Minigrace behaviour here is not correct (based on previous email
discussions we've already had about this). The request for 'apply' on the block
in the for() do() method should complain that it has been passed too many
arguments. You should do either this:

  for (1..3) do { _ ->
    print 5
  }

Or something like this:

  method do(count) times(block) {
    for (1..count) do { _ ->
      block.apply
    }
  }

  do 3 times {
    print 5
  }

-- 
Tim


More information about the Grace-core mailing list