I wonder if a type of “native language escape” functionality could be added to Monkey. Similar to C how you can escape from the C language and then you can program in Assembly almost seamlessly. However, since monkey is translated to multiple languages, I figure it wouldn’t be too difficult to tell the translator to ignore all syntax from a certain directive to the specified end, then include the raw code in the appropriate build/target. Explanation by Example:
Monkey
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
' Here is monkey code
FunctionDoSomething:Void()
End
#Native<JS>' Write Raw JS(Emscripten)
functiondo_something(){
//Write some JS only code
}
#EndNative
#Native<CPP/C>' Write Raw C/++
intdo_something(){
//Write someC/++only code
return0;
}
#EndNative
For now just keep the identifier scope within the pre-processor directive things.
Not sure how practical this would be in practice, but I’m sure it would be useful in very special cases.