weistn / gismo

Programming language with extensible syntax
3 stars 0 forks source link

Multiple source files in src/ #6

Closed weistn closed 10 years ago

weistn commented 10 years ago

Currently all files in src/ are compiled and the compiled code is concatenated. This way the files can end up with colliding imports.

Example: file1.gs import "foo" as bar var foo = 12

file2.gs import "foo"

The second import will overwrite the value 12.

Proposed solution: Instead of generating var bar = require('foo') we should generate var __module_1 = require('foo') and replace all top-level occurrences of 'bar' in file1.gs with __module_1. This way imports do not collide

weistn commented 10 years ago

Other solution:

Every file is wrapped in a function

(function() { ... file_1 var y }());

(function() { ... file_2 var y }());

Module global variables can be accessed via 'module.a'. Global process variables can be accessed via 'global.a'.

weistn commented 10 years ago

Implemented