Version française
Home     About     Download     Resources     Contact us    
Browse thread
Preventing values from escaping a context
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Miles Sabin <miles@m...>
Subject: Re: [Caml-list] Preventing values from escaping a context
On Tue, Feb 9, 2010 at 3:38 AM, Jacques Garrigue
<garrigue@math.nagoya-u.ac.jp> wrote:
> From: Rich Neswold <rich.neswold@gmail.com>
>> My question is this: Is there a way to make the compiler reject a function
>> parameter from returning the context parameter? For instance, the identity
>> function should be disallowed since the context is invalid outside the scope
>> of 'usingContext'. It's true that a returned context would be unusable,
>> since its resources are gone, but it would be nice to prevent contexts from
>> escaping the 'usingContext' function entirely.
>
> The short answer is no.
> Types are not sufficient to prevent values from escaping.

I appreciate that mention of Scala is borderline off-topic on this
list, however that's a very broad negative statement, so broad
counterexamples seem appropriate ... ;-)

Philippe Haller of EPFL is working on a uniqueness types extension of
Scala which provides exactly this, packaged as a compiler plugin for
scalac (my hope is that it will be rolled into the main scala
distribution during the 2.8.x series, so this isn't solely academic
exercise).

An example here,

  http://tinyurl.com/ya6f7jv

and the corresponding compiler-time error,

  http://tinyurl.com/yzgnus5

Full details can be found in his technical report here,

  http://lamp.epfl.ch/~phaller/capabilities.html

Scala isn't the only language which supports linear/uniqueness types,
however it's the only which does and has some prospect of becoming
mainstream.

Cheers,


Miles

-- 
Miles Sabin
tel: +44 (0)7813 944 528
skype:  milessabin
http://www.chuusai.com/
http://twitter.com/milessabin