"Nick Kallen" <[EMAIL PROTECTED]> writes:

> > > > If this is true, then what I'm doing is horrible. But I don't
> > see how this
> > > > leads to nondeterminism or broken referential transparency.
> > min2 returns the
> > > > same value for the same list, but it's simply more efficient
> > if we happen to
> > > > know some more information about the list.
> > >
> > > In this particular case that happens to be so.  But it's not true in
> > > general.  What if the body of min2 were defined so that it returned
> > > something different in the two cases?  Your code has no proof that the
> > > code for the two cases is equivalent.  If it's not, then the behaviour
> > > would depend on whether the compiler could deduce that a particular
> > > argument had type Sorted or not.  And that in turn could depend on the
> > > amount of inlining etc. that the compiler does.
> 
> I'm not asking the compiler to deduce anything. I'm talking about run-time
> type matching; this is dynamic types!

Ouch.  I hadn't realized this, although I should have.

I think you're going to run into severe efficiency/implementation
problems if you try to implement an approach like this.  As far as I
can tell, you need to store a potentially very large set of type
information with every object (every list cell, etc.), and you need to
figure out ways to efficiently create and query this type
information.  Sounds tough.

Carl Witty
[EMAIL PROTECTED]


Reply via email to