This is a living document storing some ideas for extensions & improvements that I might make to the Monkey programming language, interpreter, evaluator, compiler, and/or virtual machine implementations.
- Support floating-point numbers (currently only integers are supported)
- Add support for
else ifwithin conditional expressions - Allow for reassignment of values to variables declared with let
- Support
constbinding declarations in addition tolet - Logical boolean operators (
&&,||) - Modulus operator (
%) - Add
//(integer division) as a separate operator from/ - Support
+=,-=,*=,/=,//=operations - Add exponentiation operation with
** - Additional comparison operators (
>=&<=) - Strings: comparison with
==&!= - Arrays:
+operator - Implement
whileloops - Add basic support for
forloops - Add support for
breakandcontinueinwhileandforloops - For
forloops, theInit,Condition, andAfterthoughtexpressions are all currently required - maybe allow for these to be optional - Add basic support for
switchstatements -
switchstatements currently just use equality (==) for comparison - maybe allow for switching based on the type of some variable, like in Go - Maybe support postfix operators
++and-- - The lexer (
lexer/lexer.go) currently only supports ASCII characters. Maybe extend this to Unicode (see p. 19-20 in WAIIG). - Add support for macros into the compiler/VM engine (supported in interpreter but not yet compiler/VM)
- Add support for hashmaps in the
lenbuiltin function - Strings:
splitoperation - Arrays:
joinoperation - Arrays:
sum - Arrays:
map - Arrays:
filter
- When opening a REPL, ability to select interpreter/evaluator or compiler/VM engine
- Implement better printing of functions to the console (currently looks like:
Closure[0x140000ce160]) - Ability to navigate back and forth in REPL input with arrow keys & do multi-line input (look into readline package)
- Ability to execute Monkey programs from files (
.moextensions?) - again, be able to choose engine - Better error messages that point to line/column numbers for problematic tokens, both at compile-time and run-time
- Ability to include comments in Monkey code
- Maybe write a UI to interact with Monkey -
wadackelhas written a great example of this: https://github.com/wadackel/rs-monkey-lang
- Rely on an intermediate representation (IR) between the AST and bytecode, potentially to improve performance or simplify operations
- Can potentially implement additional benchmarks for comparing the interpreter/evaluator to compiler/VM: arithmetic operations, string concatenation, Sieve of Eratosthenes, etc.
- Keep README documenting language features & implementation up-to-date
- Maybe refactor some code files/split into more files (some files are getting pretty long)
- In the
*ast.InfixExpressionhandling incompiler/compiler.go, is it worth just adding anOpLessThanbytecode instruction so that this case doesn't have to be handled separately from the rest of the logic? - In the AST modification functionality (
ast/modify.go), implement thorough error-checking