[Grace-core] Type declarations in Grace

Kim Bruce kim at cs.pomona.edu
Thu Jun 9 09:50:19 PDT 2011


Bertrand has infiltrated our group!

I'm impressed that they have money for ads!

Kim



On Jun 9, 2011, at 8:45 AM, Andrew P. Black wrote:

> Reading your email on Gmail, Google found the following ad to place at the bottom:
> 
> Tired of Java, C++, C#? - Try Eiffel: simple and powerfulAd
> Another approach for better results
> www.eiffel.com
> 
> I guess that says it all: we should just quit and adopt Eiffel.
> 
> 
> 
> On Tue, Jun 7, 2011 at 5:17 PM, Kim Bruce <kim at cs.pomona.edu> wrote:
> Types of variables as shown through interfaces:
> 
> The look of
> 
> x:=(v: T) -> Unit
> 
> as a declaration is pretty ugly. ...
>  
>  I would likely prefer the syntax I suggested:
> 
>             year: Int
> 
> or
> 
>             year: Int <writeonly>
> 
>              year: Int <readwrite>
> 
> As a second choice, I’d prefer the setYear syntax, i.e.,
> 
> o.setYear(Number) -> Unit
> 
> used as
> 
>             o.setYear(2009)
> 
> understanding the issues with the change in capitalization.  I could also live with the year:= form if necessary, but it does make me cringe a bit.
> 
> (Again, keep in mind we are selling dogfood.  If instructors cringe that may be a problem even if students accept it!)
> 
> 
> If we are calling the methods year and year:=(), then I really can't see any reason to introduce a new syntax in type declarations, just so that we have to explain the mappings:
> 
> year: Number                       =>     year -> Number and year:=(Number)
> year: Number <writeOnly>    =>      year:=(Number)
> year: Number <readOnly>     =>      year -> Number
> 
> Now, it is indeed true that when /implementing/ an object, we have to explain that one field can give rise to one or two methods.  (I think that this will be easier to teach if we distinguish between self.year (a method request) and year (a variable reference).  But having explained to students that the type of an object is nothing more than a list of its methods, with their argument and result types, it seems clear what the type of an object that contained the field year would be.  Introducing something different just so that instructors have to explain it as being the same seems overly complicated.  
> 
> What am I missing?
> 
> On a different note, is there a reason to require the writing of -> Unit to indicate no result, rather than just omitting the -> altogether?  
> 
>     Andrew
> 
>  
> _______________________________________________
> Grace-core mailing list
> Grace-core at cecs.pdx.edu
> https://mailhost.cecs.pdx.edu/mailman/listinfo/grace-core

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailhost.cecs.pdx.edu/mailman/private/grace-core/attachments/20110609/0f06b54a/attachment-0001.html>


More information about the Grace-core mailing list