[Grace-core] In praise of consistency

Kim Bruce kim at cs.pomona.edu
Fri May 18 16:09:33 PDT 2012


Kim



On May 18, 2012, at 3:37 PM, Andrew P. Black wrote:
...
> 
> If we just want to be consistent, and don't want to usurp bracts for application (which will look really ugly when the arguments are blocks), then I think that we could use these two forms:
> 
> 
> 	print "hello".reversed on output.mainStream
> 
> and
> 
> 	print ("hello".reversed on output.mainStream)
> 

My major concern is that we avoid syntax that can reasonably be interpreted in two different ways.  I don't mind forcing programmers to type extra characters to avoid that, if that is what is necessary.  My problem with the first way of writing above is that it can be interpreted in (at least) two different ways.  (The second has fewer reasonable interpretations.)  I'd rather the first result in a message that you need to add parentheses to disambiguate it than to have it automatically interpreted in a way that the student might not expect.

Another example of something that I found annoying/difficult because of inconsistency has to do with type inference in Scala.  Most of the time one could leave out return types on methods and in variable declarations.  However, that is not always true (e.g., return types in recursive methods in Scala and many instance variables).  Novices need consistency (or at least predictability) as Michael Kölling has reminded us.

Coming back to your original argument, yes, we are using parentheses for different purposes, but they are close enough that neither novices nor experienced programmers have any real difficulty with them.

I keep wondering whether we should fall back on the Smalltalk convention/rule of requiring a colon at the end of the segments of the method name as that would help disambiguate some of these cases (and Smalltalk programmers seem to have little trouble with this -- is that true Andrew?).

Kim
> 
> 
>> 
>> 
>> 
>> On May 18, 2012, at 10:21 AM, Andrew P. Black wrote:
>> 
>>> So, I think that Kim and Michael are both saying that the two forms should be
>>> 
>>> 
>>> 	print ("hello".reversed) on (output.mainStream)
>>> 
>>> and
>>> 
>>> 	print ("hello".reversed (on (output.mainStream)))
>>> 
>>> 
>>> Is that right?
>>> 
>>> 	Andrew
> 



More information about the Grace-core mailing list