[Grace-core] An error or ???

Kim Bruce kim at cs.pomona.edu
Wed Jun 25 16:20:27 PDT 2014


The following program is (I believe) technically wrong.

for(1..3)do{
   print(5)
}

It should require an index variable and arrow after "{".  Minigrace allows this and does the intuitive thing (print "5" 3 times).  Not surprisingly if the body depends on an undeclared index variable then it chokes.

The spec (section 9.1) illustrates only the version with the index variable and arrow.  Should we consider the above an error in minigrace (and fix minigrace to report it as such) or do we want to admit it when the body does not depend on the index variable.  I lean toward considering this to be an error, but could be convinced otherwise.

Kim

P.S.  In my previous e-mail I was concerned about not being able to access "for" with an "outer" prefix.  The spec seems to indicate that should have been possible.  Here is verbiage from section 9.1 of the spec.

For statement:

for (collection) do {item −> block body}

for (course.students) do { s:Student −> print s }

for (0..n) do { i −> print i }

To allow for conventional syntax with a leading keyword (if, while, for, etc.), these methods are treated as if they are sent to outer. Methods defined in a dialect are treated as if they are defined on an outer-level enclosing object.  


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


More information about the Grace-core mailing list