[Grace-core] [Minigrace] type issues in minigrace

Michael Homer mwh at ecs.vuw.ac.nz
Fri May 25 21:19:56 PDT 2012


On May 26, 2012 3:33 PM, "Andrew P Black" <black at cs.pdx.edu> wrote:
>
>
> On 25 May 2012, at 18:56, Michael Homer wrote:
> >>
> >>
> >> type T = {Number->Number}
> >> ...
> > More than that - it's actually a perfectly valid type, to which this
> > object belongs:
> >  object {
> >    method Number -> Number { 1 }
> >  }
>
> I recall discussing, at some pint n the distant past, whether we should encircle case conventions.  Like method names must begin with a lower case letter.   If we want students to do stuff like that, it's probably better to enforce it.
But types (I think) can appear inside objects or other types, and so
have to appear as method names there. At least you'd need to be able
to write the type of that even if using it as the name of a method you
wrote wasn't allowed.
> >> type T = {apply: Number->Number}
> >>
> > The runtime error is because the type has three viable method names in
> > a row ("apply", ":", and "Number"),
>
> Is : a valid method name?  I thug that it was reserved to mean "here comes a type annotation".   Is it really wise to try and use it for both purposes?
It's not supposed to be, type-context parsing just doesn't pay enough
attention to what kind of token it's getting to reject it. I do have :
as a valid operator character when it's combined with others, but
perhaps it shouldn't be that either.
-Michael


More information about the Grace-core mailing list