[Chicken-users] Redefinition of imported binding gets implicitly exported

2013-10-25 Thread Andy Bennett
Hi,

With the following in m.scm:

-
(module m
 (do-something)

 (import chicken scheme)
 (use posix)

 (define process (make-parameter 'hello))

 (define (do-something)
  (printf Doing something...\n))
 )
-

...and compiled thusly:

csc  -s -O2 -d1 m.scm -j m -o m.so
csc  -s m.import.scm -O2 -d0 -o m.import.so

...on Chicken 4.7.0 or 4.8.0.4 and maybe others,

I get the wrong binding for process when I (use m):

-
#;1 (use m)
; loading ./m.import.so ...
; loading ./m.so ...
#;2 (process)
hello
-


...even tho process is not exported from the module m.


Interestingly I wasn't getting this on my development machine but when I
deployed some new code last night I discovered that the binding was
being redefined on the deployment machine even tho' the version of
Chicken was the same. I'm not sure if it has anything to do with the
order in which modules are loaded.

Surely the new definition should shadow the existing one, not redefine it?

The behaviour exists even if the module is imported with a prefix:

-
#;1 (use (prefix m m:))
; loading ./m.import.so ...
; loading ./m.so ...
#;2 (process)
hello
-


I'm not sure if this happens with definitions from other eggs rather
than so called units.


When compiling m.scm - m.so I get the following warning:

-
Warning: redefinition of imported value binding: process
-




Is this behaviour considered a bug?





Regards,
@ndy

-- 
andy...@ashurst.eu.org
http://www.ashurst.eu.org/
0x7EBA75FF


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Redefinition of imported binding gets implicitly exported

2013-10-25 Thread Andy Bennett
Hi,

 I get the wrong binding for process when I (use m):
 
 -
 #;1 (use m)
 ; loading ./m.import.so ...
 ; loading ./m.so ...
 #;2 (process)
 hello
 -

Of course... I was expecting the posix unit's binding for process:

-
#;1 (use posix)
; loading library posix ...
#;2 process
#procedure (process cmd2077 . tmp20762078)
#;3 (use m)
; loading ./m.import.so ...
; loading ./m.so ...
#;4 process
#procedure (f_12177 . args2448)
#;5 (process)
hello
-



Regards,
@ndy

-- 
andy...@ashurst.eu.org
http://www.ashurst.eu.org/
0x7EBA75FF


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Redefinition of imported binding gets implicitly exported

2013-10-25 Thread Evan Hanson
Hi Andy, all.

I looked into this recently since it also seemed like a bug to me, but
the behavior seems to be intentional judging from the code.

A workaround is to exclude `process` from the import list in `m` (as in
`(import (except posix ...))`) -- this prevents the behavior you're
seeing, at least.

When `##sys#alias-global-hook` is used to resolve an identifier name for
an assignment, it's called with the already-looked-up name from the
environment and shortcuts when that identifier is already aliased,
returning the imported name (in this case, the built-in `process`)
rather than a new, module-prefixed identifier that would shadow the
binding like you said.

It seems to me that when `##sys#alias-global-hook` is used to resolve
names for `set!` forms, it should be called with the bare
(pre-se-lookup) identifier, and when `assign` is true and you're
currently in a module it should always create a module-prefixed
identifier and update the environment, instead of returning the existing
alias for imported symbols. But, I couldn't get this to work without
breaking other things.

CC'ing -hackers.

Evan

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users