Compiler/Simple file inclusion pre processor: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (syntax highlighting fixup automation)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
Line 740:
 
Nevertheless, it is possible to write a limited pre-processor in Wren (the VM itself is written in C):
<syntaxhighlight lang="ecmascriptwren">import "io" for File
 
var source = File.read("source.wren")
Line 769:
 
The obvious solution of placing the imported code in a block and then 'lifting' the specifically imported variables into the outer scope does not work because of Wren's rather strange scoping rules. If you did this, then the imported module's top level variables would no longer be top-level relative to the code as a whole and hence would no longer be visible to classes defined within the module itself! For example, if you try to run the following script, you get the error shown:
<syntaxhighlight lang="ecmascriptwren">var B
 
{ // block starts here
9,476

edits