[Grace-core] Type declarations in Grace

Andrew P. Black black at cs.pdx.edu
Thu Jun 9 08:45:24 PDT 2011


Reading your email on Gmail, Google found the following ad to place at the
bottom:

Tired of Java, C++,
C#?<http://pagead2.googlesyndication.com/aclk?sa=L&ai=B8eHRfebwTenTGZGejQSC44jSDZvLueAB45Wy3x-39_LUEcCxLhABGAEgho-AAigEOABQyOO_swVgyYaAgMyk1BmyAQ9tYWlsLmdvb2dsZS5jb226AQ5nbWFpbC1jdi1iZWxvd8gBAdoBO2h0dHA6Ly9tYWlsLmdvb2dsZS5jb20vTVRNM01UQXdOVEF5TkRNNU5qUTFNRE14TjBWWVVFRk9SRVZFgAIBqAMB6APcBegDH_UDAAAARA&num=1&sig=AGiWqtzEf5EcUNhYvJRqkBd0X9zOIsbqWA&adurl=http://www.eiffel.com/general/awareness/try_eiffel.html>
 - <http://pagead2.googlesyndication.com/aclk?sa=L&ai=B8eHRfebwTenTGZGejQSC44jSDZvLueAB45Wy3x-39_LUEcCxLhABGAEgho-AAigEOABQyOO_swVgyYaAgMyk1BmyAQ9tYWlsLmdvb2dsZS5jb226AQ5nbWFpbC1jdi1iZWxvd8gBAdoBO2h0dHA6Ly9tYWlsLmdvb2dsZS5jb20vTVRNM01UQXdOVEF5TkRNNU5qUTFNRE14TjBWWVVFRk9SRVZFgAIBqAMB6APcBegDH_UDAAAARA&num=1&sig=AGiWqtzEf5EcUNhYvJRqkBd0X9zOIsbqWA&adurl=http://www.eiffel.com/general/awareness/try_eiffel.html>Try
Eiffel: simple and
powerful<http://pagead2.googlesyndication.com/aclk?sa=L&ai=B8eHRfebwTenTGZGejQSC44jSDZvLueAB45Wy3x-39_LUEcCxLhABGAEgho-AAigEOABQyOO_swVgyYaAgMyk1BmyAQ9tYWlsLmdvb2dsZS5jb226AQ5nbWFpbC1jdi1iZWxvd8gBAdoBO2h0dHA6Ly9tYWlsLmdvb2dsZS5jb20vTVRNM01UQXdOVEF5TkRNNU5qUTFNRE14TjBWWVVFRk9SRVZFgAIBqAMB6APcBegDH_UDAAAARA&num=1&sig=AGiWqtzEf5EcUNhYvJRqkBd0X9zOIsbqWA&adurl=http://www.eiffel.com/general/awareness/try_eiffel.html>
Ad
Another approach for better results
www.eiffel.com<http://pagead2.googlesyndication.com/aclk?sa=L&ai=B8eHRfebwTenTGZGejQSC44jSDZvLueAB45Wy3x-39_LUEcCxLhABGAEgho-AAigEOABQyOO_swVgyYaAgMyk1BmyAQ9tYWlsLmdvb2dsZS5jb226AQ5nbWFpbC1jdi1iZWxvd8gBAdoBO2h0dHA6Ly9tYWlsLmdvb2dsZS5jb20vTVRNM01UQXdOVEF5TkRNNU5qUTFNRE14TjBWWVVFRk9SRVZFgAIBqAMB6APcBegDH_UDAAAARA&num=1&sig=AGiWqtzEf5EcUNhYvJRqkBd0X9zOIsbqWA&adurl=http://www.eiffel.com/general/awareness/try_eiffel.html>

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailhost.cecs.pdx.edu/mailman/private/grace-core/attachments/20110609/a9552c68/attachment.html>


More information about the Grace-core mailing list