Re: typechecker wish


Subject: Re: typechecker wish
From: Craig Chambers (chambers@cs.washington.edu)
Date: Tue Jan 16 2001 - 14:45:19 PST


Vass and I talked about my wish for the typechecker, and he reminded me about
the forall construct, and taught me about how to use it well. So for the
implicit extra type variables I wanted, I just have to use the forall construct
around object/type declarations to get them. E.g., instead of:

abstract object Analysis[`I <= AnalysisInfo[I],
                         `G <= AnalysisGraph[E, P],
                         `E <= IREdge,
                         `P <= AnalysisPriority[P]];

I can write:

forall `E <= IREdge,
       `P <= AnalysisPriority[P]:
  abstract object Analysis[`I <= AnalysisInfo[I],
                           `G <= AnalysisGraph[E, P]];

I can also write the I and G introductions and bounds as part of the forall,
more symmetrically with E and P, leading to:

forall `I <= AnalysisInfo[I],
       `G <= AnalysisGraph[E, P],
       `E <= IREdge,
       `P <= AnalysisPriority[P]:
  abstract object Analysis[I, G];

Also, for method declarations, I can write the extra type variables in the upper
bounds as I desired, e.g.:

method analyze(analysis:Analysis[`I, `G <= AnalysisGraph[`E, `P]],
               graph:G,
               incoming_infos:indexed[I]
               ):pair[indexed[I],
                      indexed[TransformAnalysisAction[I, G]]]
{ ... edges:indexed[E] := graph.incoming_edges; ... }

I have already made these changes, and they successfully typecheck in my
system. Victory! (At least this is as much as I can hope for with the current
Cecil type system. I still think that named type parameters, which can be left
unmentioned when not needed, would be a lot better. For Diesel.)

-- Craig



This archive was generated by hypermail 2b25 : Tue Jan 16 2001 - 14:45:27 PST