Robert Feldt wrote:
Hi,

I thought the following would print "Hello" to stdout but it does not:

feldt:~/tmp/nekotest$ cat t1.neko
puts = function(str) {
  $print(str + "\n");
}
feldt:~/tmp/nekotest$ cat t2.neko
puts("Hello");
feldt:~/tmp/nekotest$ nekoc t1.neko t2.neko
feldt:~/tmp/nekotest$ nekoc -link t3.n t1 t2
t1
t2
feldt:~/tmp/nekotest$ neko t3
Called from t2.neko line 1
Uncaught exception - Invalid call

Can you explain how the global context works when linking modules?

Globals are "per module" at runtime so when linking it's normal that globals are not merged either. (this ensure also the sandbox : several versions of the same module can be loaded and they will not share the same global table). If you want to communicate between modules you need to use the $export table.

Nicolas

--
Neko : One VM to run them all (http://nekovm.org)

Reply via email to