[Haskell-cafe] Re: [Haskell] Top Level <-

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Mon Sep 1 18:15:22 EDT 2008

On 2008 Sep 1, at 18:08, Ganesh Sittampalam wrote:
> On Mon, 1 Sep 2008, John Meacham wrote:
>> On Mon, Sep 01, 2008 at 10:45:05PM +0100, Ganesh Sittampalam wrote:
>>>> Actually all this use of the tainted and derogatory term "global
>>>> variable" is causing me to be imprecise. All MVars/IORefs have  
>>>> "global"
>>>> main/process scope whether or not they're bound to something at the
>>>> top level.
>>> "Global variable" is exactly the right term to use, if we are  
>>> following
>>> the terminology of other languages. We don't call the result of
>>> malloc/new etc a "global variable", unless it is assigned to  
>>> something
>>> with top-level scope.
>> global variable is not a very precise term in other languages for
>> various platforms too a lot of times.  for instance, windows dll's  
>> have
>> the ability to share individual variables across all loadings of said
>> dll. (for better or worse.)
> Interesting, is this just within a single process?

Last I checked, it was across processes; that is, every DLL has its  
own (optional) data segment which is private to the DLL but shared  
across all system-wide loaded instances of the DLL.  This actually  
goes back to pre-NT Windows.

>> Haskell certainly has more advanced scoping capabilities than other  
>> languages so we need a more refined terminology. I think 'IO scope'  
>> is the more precise term, as it implys the scope is that of the IO  
>> monad state. which may or may not correspond to some external  
>> 'process scope'.
> Hmm, to me that implies that if the IO monad stops and restarts,  
> e.g. when a Haskell library is being called from an external  
> library, then the scope stops and starts again (which I presume is  
> not the intention of <- ?)

It tells me the flow of execution has temporarily exited the scope of  
the IO monad, but can return to it.  The state is suspended, not exited.

brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH

More information about the Haskell-Cafe mailing list