This repo keeps track of potential and planned features for YASL, to avoid cluttering the main repo.
Possible future features:
Strings:
- add
string.reversemethod. add string metatable.(done)- add
\uNNNNescapes in string literals. - add
\UNNNNNNNNescapes in string literals.
Numbers:
- add "character literals". These would have type
int, based on the character code given. examples would be?afor0x61,?\nfor0x0A, or??for0x3F(all assuming we're using ASCII).
Lists:
list metatable.(done)
Tables:
metatables, to allow lookups in a second table if first look-up fails.(done)
Userdata:
metatables(done)
in operator:
check list and table containment. complement is(won't do)!in.
For loops:
- allow iterating over two values instead of just 1.
for let i, v <- [2, 3, 5, 7] {}would haveiiterate over the keys, (0, 1, 2, 3) andviterate over the values (2, 3, 5, 7).
Operator overloading:
Libraries:
- UTF8 library (
utf8), including string functions on utf8 strings. I/O library ((done)io), including file I/O and stdin, stdout, stderr.- coroutine library (
coroutine), for concurrency. collections library ((done)collection), including collections such asset,multiset, and typed arrays.- regex library (
re). Something like PCRE is likely too big for usage in the standard library.
Functions:
Implement full lexical closures.(done)allow unnamed functions using(done)fn(a, b) { return a + b }.- allow
expr string-literalas a function call. e.g.utf8'string'would be the same asutf8('string').utf8'string'->toint()would be the same asutf8('string')->toint. This would allow something similar to the string prefixes found in Python, without having to add too much to YASL. - Add functions that allow arbitrary arguments.
Sequences:
- "sequences" should be added to YASL. sequences live only on the stack. Trying to use a sequence in an expression will shrink or expand the sequence to the appropriate size. e.g. if
f()returns1, 2,x, y = f()will use both values.x = f()will shrink1, 2to fit the context it is used in, to1in this case.x, y, z = f()would expand1, 2to the context it is used in, filling withundef, soxwould get a value of 1,ya value of 2, andza value ofundef.
Comprehensions:
- comprehensions should be more general, returning a sequence. This would allow stuff like
max(x for x <- ls if x > 0), andset(x for x <- ls). - If iterating over multiple values is allowed, comprehensions should also support this.
Control Flow:
- Optional
elseclause in loops, executed if the main loop doesn'tbreakout. - Pattern matching.
Variables:
Allow multiple assignments of the form(done)x, y, z := 1, 2, 3. Allowconst x, y, z := 1, 2, 3as well, which makes the first of themconst.
Generators:
fn* gen(a) { /* body */ }to declare a generator (compare with notation for function declarations).-x for* x <- lsto declare a generator from an existing iterable (compare with notation for comprehensions).
Internal Changes:
- Fold method calls involving literals at compile time.
- Fold anything involving
constvariables that can be determined at compile time. - Fold conditionals at compile time.
- implement string interning with all literals.