chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Variable Capture in message-digest


From: Andy Bennett
Subject: Re: [Chicken-users] Variable Capture in message-digest
Date: Tue, 26 Apr 2016 12:00:14 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.7.0

On 26/04/16 09:40, Peter Bex wrote:
> On Tue, Apr 26, 2016 at 09:26:55AM +0100, Andy Bennett wrote:
>> Thanks Peter!
>>
>> That is rather confusing: I thought each module imported its own
>> identifiers and had its own namespace.
>
> It does, but the identifiers which you import are simply aliases
> for the same thing, so if you set! one, you set! all of them.
>
> It may make more sense if you remember that modules disappear when
> compiling; the identifiers all get replaced by their canonical name,
> so if you (import (rename foo (bar my-weirdly-renamed-bar)))
> it rewrites all my-weirdly-renamed-bar to foo#bar.
>
> Thus, (set! my-weirdly-renamed-bar 42) is equivalent to (set! foo#bar 42)
>
>> As string->blob is part of "library" I'm not importing it from anywhere
>> so how would I "except" it?
>
> It's in the "chicken" module, so (import (except chicken string->blob))
> should do the trick.  Library is just the unit that defines this module's
> identifiers.  Yeah, this is confusing, and weird.  Hopefully we'll fix
> this situation with CHICKEN 5, where we'll define the modules more
> explicitly, and probably restructure the manual to match.

I see.

My model was that when you imported a module it did something like (set!
bar foo#bar) rather than polluting the top level by conflating bar and
foo#bar.


Instead, it seems that if a module exports an identifier and uses that
identifier internally it is possible for the user of the module to
interfere with it. I guess that's entirely reasonable given the
"procedures as first class values" thing: I'd totally expect the
behaviour that you describe if the identifier referred to any other
value than a procedure.


Thanks again!



Regards,
@ndy

-- 
address@hidden
http://www.ashurst.eu.org/
0290 DA75 E982 7D99 A51F  E46A 387A 7695 7EBA 75FF


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]