[bitc-dev] BitC Records Figure fixed
Jonathan S. Shapiro
shap at eros-os.org
Mon Dec 27 08:39:38 EST 2004
On Sun, 2004-12-26 at 16:27 -0500, Swaroop Sridhar wrote:
> > Let's try to give more complete examples so that we can really look at
> > them. I think you are concerned with something like:
> >
> > (defstruct s1 a:int b:float c:int)
> > (defstruct s2 a:int m:float n:float c:char)
> >
> > Note that in these structures, the 'c' members disagree on both position
> > and type. Now the question you pose is: "what is the type of 'x' in:"
> >
> > (defun f x (x.a + a.b))
> >
> > It would seem that there are two possibilities here:
> >
> > 1. By filtering against field names, the inference engine concludes that
> > the type must be either s1 or s2, but it cannot uniquely resolve the
> > type. Automatic type resolution therefore fails, and the user is
> > required to specify the type explicitly, as in:
> >
> > (defun f x:s1 (x.a + a.b))
> >
> > 2. The inference engine concludes that the type must be either s1 or s2,
> > and is not unique. We resolve this by polyinstantiating f.
> >
> > In abstract, I think that the preferred answer is probably (2), but I
> > don't understand what implications this may have when 'f' is later used
> > as a procedure parameter. What am I missing?
> >
> >
>
> s2 is not a candidate for function f, as it does not have a field named
> 'b'.
My apologies. I miswrote the defun. It should have read:
(defun f x:s1 (x.a + a.b))
shap
--
Jonathan S. Shapiro <shap at eros-os.org>
More information about the bitc-dev
mailing list