So yeah--very very alpha version of tinylisp 2 is out and can be demoed on Replit! Most of the core language is there, it's just missing a lot of the "nice" features and a lot of library functions.
2
New features include lexical scope, better macro system, syntax for default arguments, a dedicated String type, ; for comments, and autoloading the core library.
Note that many of the builtins now use long names by default (e.g. cons instead of c); the library with the single-character versions is not autoloaded yet, but for the present it can be manually loaded with (load lib/short-names).
@PyGamer0 Yes--note also that because of how strings are implemented, some string operations are just the same as the corresponding list operations. For example, reverse and concat work on both strings and lists.
@PyGamer0 Yeah, that's something I'll look at adding. Though I do also like the autocomplete-at-end-of-line feature... I wonder if there's a way to have both.
@PyGamer0 ~ is "swap" in some languages--it seemed to fit the "put the end at the beginning and the beginning at the end" idea. I'm open to other suggestions.
That's a possibility. I had tentatively associated $ with macro, but 1) that's flexible, and 2) I'm not sure whether macro needs a 1-character version. I don't think it'll be used much in golf.
Basically, macros and functions have switched syntax from original tinylisp. Functions are now lists of three elements (environment params body), and macros are lists of two elements (params body).
Speaking of macros: in library code, I like prefixing the names of macro arguments with a sigil to distinguish them from functions. Onions on & vs $? (Or another option?)
E.g. (macro (&num) (- &num 1)) vs (macro ($num) (- $num 1))
@Razetime Yeah--it's still pretty minimal (around 20-22 builtins as compared to 17 in tinylisp 1), but it has a few more capabilities. Lexical scope is so nice (and a lot easier to implement than I thought it would be).
I copied large parts of the structure of the interpreter from Appleseed, which already had a number of the same improvements over tinylisp (as well as a bunch of other stuff which I didn't want for tinylisp 2).