Each class and each function or method have its own namespace, so general functions defined somewhere "outside" aren't easily accessible, you have to move up through the self
keyword (for example: self.self.self.math.sin
) or it must be available through the global namespace (global.math.sin
), which doesn't look much better, either. So I added a concept of modules to SilverScript. Modules are just classes in the global namespace, but usually you declare that you are using a certain module in the beginning of a function. I added the keywords use
, as
and module
to the language.
I also added the @-operator to SilverScript. If you prepend it to an identifier, the interpreter searches the namespaces up to the first set variable of the given name. It's useful if you want to create a class instance from another class.... read more
I'm so glad that explicit class implementation is working now! Before I could already "convert" variables to classes (or objects) by just setting an attribute of it. Now it is possible to "declare" and implement a class about like you are used to in C like languages :)
I hope I get working functions soon, and arrays and strings should be get done quickly then, too, then I will upload the complete language design PLUS source code :)
My Lexer (code string -> tokens) and Parser (tokens -> bytecode) is already fully working (but the latter still need more code checking). The main work is currently in the Interpreter, which actually executes the bytecode.
A working Parser means that complex expressions (order of additions, multiplications, parentheses, etc.) are already working, using the Shunting-yard algorithm.... read more