[Grace-core] Pondering types

Michael Homer mwh at ecs.vuw.ac.nz
Fri Mar 7 14:13:14 PST 2014


On Sat, Mar 8, 2014 at 12:08 AM, Kim Bruce <kim at cs.pomona.edu> wrote:
> [A long post on some aspects of the type systems.
> Comments/corrections/questions are welcome.  I find that writing things down
> helps me think about them, but discussions help clarify the ideas.]
>
> Types in Grace
>
> The following was inspired by my conversation with Tim (and Michael) about
> types in Grace.  Some we discussed in Wellington, but other parts are my
> further thoughts.  I’m focusing on static typing in Grace, but some parts
> (e.g., the introduction of SelfType) may have some impact on the core
> language as well.
>
>  1.  Use of types defined as part of objects and/or classes:
>
> Types defined in objects are not actually parts of those objects, but
> instead are defined to have the object as their scope.  However, these type
> definitions are accessible outside of the object when qualified by the name
> of the object (e.g., type definitions are implicitly public).  There are a
> few consequences of this that I enumerate below.
>
>  a.  Types defined in an object o do not show up in o’s type.  That is,
>
> def o = object {
>    method m(a:T)->T{…}
>    def U = {n -> Number)
I assume that's meant to be a type declaration.
>    method p -> U {…}
> }
>
> has type {m(a:T) -> T, p -> o.U}.
(On that basis) it has type {m(a:T) -> T; U -> Pattern<o.U,Tuple0>; p -> o.U}.
-Michael



More information about the Grace-core mailing list