Summary

define-external variables can't be exported

Metadata

Description

This program fails to compile:

 (module test (x)
   (import foreign scheme chicken)
   (define-external x int 123))

If you don't wrap it in a module, x doesn't exist if you load the shared object you get from csc -s.

Changes and comments

[2017-02-27 17:26:08 UTC] LemonBoy wrote:

Here's a patch patch addressing this problem.

[2018-11-07 22:33:59 UTC] sjamaan changed milestone from someday to 5.1

[2018-11-07 22:33:59 UTC] sjamaan wrote:

Let's try to fix this in 5.1. It's still relevant.

[2019-04-07 12:23:24 UTC] sjamaan changed milestone from 5.1 to 5.2

[2019-04-07 12:23:24 UTC] sjamaan wrote:

Getting ready for 5.1, moving tickets which won't make it in to 5.2.

[2019-08-25 10:53:04 UTC] felix wrote:

You cannot export a foreign variable - it is not a variable that doesn't have normal Scheme semantics, it may be a volatile memory location and any Scheme variable bound to this will be completely detached. Note that the situation for callback-functions is different, the Scheme part can be called externally and refers only internally to the foreign entity (a function in this case).

I recommend to signal an error when a foreign-variable is appearing in an export list.

[2019-08-25 13:10:03 UTC] felix wrote:

A patch has been posted for this, but it is probably not complete. We could also check for names defined by `define-constant` and `define-type` as well...

[2019-08-25 13:10:16 UTC] felix changed status from new to assigned

[2019-08-25 13:10:16 UTC] felix set owner to felix

[2019-09-14 16:11:18 UTC] sjamaan wrote:

Patch has been applied. Should we keep this ticket here or move to 5.3 for the remaining things?

[2019-10-04 20:13:30 UTC] felix wrote:

A patch for detecting all other entities has been submitted to chicken-hackers.

[2019-10-06 11:44:21 UTC] felix changed status from assigned to closed

[2019-10-06 11:44:21 UTC] felix set resolution to fixed