This repo keeps track of potential and planned features for YASL, to avoid cluttering the main repo.
Possible future features:
Strings:
- add
string.reverse
method. add string metatable.(done)- add
\uNNNN
escapes in string literals. - add
\UNNNNNNNN
escapes in string literals.
Numbers:
- add "character literals". These would have type
int
, based on the character code given. examples would be?a
for0x61
,?\n
for0x0A
, 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 havei
iterate over the keys, (0, 1, 2, 3) andv
iterate 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-literal
as 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, 2
to fit the context it is used in, to1
in this case.x, y, z = f()
would expand1, 2
to the context it is used in, filling withundef
, sox
would get a value of 1,y
a value of 2, andz
a 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
else
clause in loops, executed if the main loop doesn'tbreak
out. - Pattern matching.
Variables:
Allow multiple assignments of the form(done)x, y, z := 1, 2, 3
. Allowconst x, y, z := 1, 2, 3
as 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 <- ls
to 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
const
variables that can be determined at compile time. - Fold conditionals at compile time.
- implement string interning with all literals.