On 5 January 2014 15:41, Jonathan S. Shapiro <[email protected]> wrote:
> On Sat, Jan 4, 2014 at 7:05 PM, William ML Leslie
> <[email protected]> wrote:
>>
>> On 4 January 2014 12:40, Jonathan S. Shapiro <[email protected]> wrote:
>> > Does this idea that instances of interfaces have a lifetime restriction
>> > work? What do people think?
>>
>> I like it.
>>
>> Does it work?  Well, without having formalising it in a Tofte-Talpin
>> derivative; I /think/ it works.
>
>
> I'm afraid I asked a poorly specified question. I'm completely certain that
> it works from a typing perspective. My intended question was: does this feel
> like it should work pragmatically?

Sorry, I understood that much.  But formalising it allows us to ask
the right questions: when and how does it fail?  In those failure
cases, are there obvious solutions?  How obvious - can solutions be
found algorithmically, or is there some obvious direction that the
programmer can give us to fix it?

I mean, my immediate reply (the one starting with the involuntary
"Erm") is just one of those cases.

Perhaps there are pragmatic questions that do not fit that frame, but
it felt like a good place to start.

>>  This is one of those cases where it
>> would be convenient to run an analysis over a large body of code to
>> see if this is how people are using interfaces, and for those cases
>> that they are not, how often one of the obvious solutions can be used.
>
>
> Yes and no. It's good to understand existing usage. But much depends on what
> idioms the language encourages.

Well, the question is, how should I do /this/ in bitc? Do I not do it?

The "immediately cast to an interface" pattern for example is pretty
common.  I often want to store collections of some interface, in
particular.

> It's a violation of the NoHeap effect, so it would show up as a type error.
> In practice, this should only occur with interfaces to objects of reference
> type, which are themselves already heap allocated. If so, there are
> pre-existing noheap violations.

But the problematic case is where an interface captures a value that
it outlives.  It seems to me that you are suggesting that this case
is:

* I have a value V which I cast to an interface W
* Region analysis infers r(W) > r(V), so the interface outlives the value
* Static allocation pass rewrites V to be heap-allocated
* NoHeap check detects violation

I can't be /sure/ that you mean this, but it sounds a bit magical to
me.  I would probably be really confused as to /why/ V was heap
allocated.  I want more information.

And really, I think this condition is more accurately described by the
region system.  "V may outlive W, but references it."

-- 
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