Releases: bananu7/Turnip
Improved REPL & command line
This is a relatively minor update on the inside - two bugs were fixed, most importantly the very finnicky #70. From the usability, PoV though, this is quite big.
The REPL now allows executing both statements and expressions. This means that there's no need for prefixing them with return
- just 1+2
will work. It will also accept blocks with no results (such as function declarations) without unnecessary error messages.
In the same spirit, the main executable now uses a proper command line argument parsing, and includes a --file
switch for loading files from disk for execution prior to going into the interactive mode.
Parsing numbers
Again what seems like a minor addition represents months of work and that one long weekend. I've learned that parsing number is a really annoying and complex task.
It became a bit easier when I realized I can use the strength of Parsec to parse the contents of the literals (or just values) passed to tonumber
. That didn't really help with the conversion process. This became much more reasonable once I realized that while Lua allows numbers in arbitrary bases, it only does that for integers; floating-point numbers are restricted to base 10.
This means I can delegate the base-10 parsing to existing, good implementations, and just do the base-n integers myself. I still don't particularly like this implementation, but since it lives in its own, isolated module, I can improve it whenever I feel the need for it.
One additional caveat is that I found a bug in the actual parser; it doesn't allow numbers starting or ending with a dot, which got an issue with an apt number #69. This will be solved separately.
Safe evalHead
This is an incredibly minor change from the outside, but important from the code safety PoV. See #3 for details.
_G and fixed operators
Refactored operators
Most of the work done is described in the #49 PR. No changes for end users, other than the fact that operators now don't reside in _G
, but I doubt that any code ever built on that.
Length operator
This release also fixes precedence of all operators, sorting them according to the Lua spec/
Concat operator
Added concatenation operator ..
and __concat
metamethod.