Perhaps I should clarify & expand.

On 9 January 2015 at 19:27, Keean Schupke <[email protected]> wrote:
> It sounds like we are saying the same thing. For specialisation to occur in
> any arbitrary function there must be only one global instance for any given
> type. It requires coherence.

For specialisation to occur in an arbitrary function, the callsite
must have fully and statically determined what is being specialised
on.  There is nothing global about this requirement.

For example, in

printStrLn $ sort i int1

the expression passes a statically determined instance.  The compiler
can freely create the specialised function sort__int1 and replace the
expression with

printStrLn $ sort__int1 i

We should note that in the process of specialising sort, we may need
to call not only methods but other functions that depend on the
type-level arguments to sort.  These are specialised accordingly, and
because this is the only way they can obtain an instance for a generic
parameter* is to be given it by the caller, there is no conflict here.

* It is possible in a system like the one we are describing for the
argument not to be generic at all, that is a much more interesting
case for inference.

> If instances are incoherent, you need to indicate which one to use by
> passing value, which prevents specialisation if the value is first class,
> because you don't know from which context the current function will be
> called.

It may be.  That is, with or without coherence, existential
encapsulation needs to be possible.

-- 
William Leslie

Notice:
Likely much of this email is, by the nature of copyright, covered
under copyright law.  You absolutely MAY reproduce any part of it in
accordance with the copyright law of the nation you are reading this
in.  Any attempt to DENY YOU THOSE RIGHTS would be illegal without
prior contractual agreement.
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to