-
Notifications
You must be signed in to change notification settings - Fork 2
/
ideas.txt
108 lines (79 loc) · 3.67 KB
/
ideas.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
List of potential ideas.
To be implemented, theese need to:
* aesthetically fit into the current Candran/Lua syntax. We can add a few weird glyphs here and there, but our goal *is not* to become a punctuation inventory like MoonScript.
* vanilla Lua code *must* produce functionaly identical code after going through the Candran compiler, so make sure the additions:
* are invalid vanilla Lua syntax.
* are not ambigous with any vanilla Lua syntax.
* be significantly useful compared to existing Candran/Lua code.
* be useful without having to rewrite APIs specifically for Candran. Candran intends to make Lua easier, not replace it.
Example rejected ideas:
* Python-style function decorators (implemented in Candran 0.1.0):
Useless 95% of the time because most Lua APIs applying something to a function are used like applySomething(someArg,func) instead of func=applySomething(someArg)(func).
This could be adapted, but this will mean unecessary named functions in the environment and it will only works when the decorator returns the functions.
In this state, these didn't provide anothing useful over short anonymous functions.
* Whitespace significance.
Doesn't fit with Lua's verbose keywords.
Of course, if you really thinks these would be useful or you found a clever way of making theses work, feel free to open an issue or pull request and discuss.
Most of Candran's additions were inspired by MoonScript, CoffeeScript, and Lilia (https://love2d.org/forums/viewtopic.php?f=3&t=82650&sid=b6d9a8dec64afcc1c67806cb5ba65458).
Please note that the following ideas are just random though and won't be necessarly implemented, and some won't even work together.
Feel free to open issues about ideas you find useful or want to improve. Otherwise, I will only implements them when I really need them or am bored.
Actually, open issues for everything. I've heard that a couple of people use Candran, but have no idea what they like and want with it.
* class keyword
class Thing(parents...)
foo = "bar"
new = :()
stuff()
end
end
local a = new Thing()
->
(TODO: define how classes work. May even use ClassCommons)
Not very Lua-ey to impose how to make your classes?
* try / except|catch / finally / else / other keywords
try
error("hey")
catch err
print(err)
finally
clean()
end
may be doable using if with assignement + pcall
* static type checking
local a = externalFunc() -- unknown
if a == "hey" then
-- a = string
a:sub(5,3) -- ok
a:exit() -- error!
else
-- a = unknown
a:exit() -- ok
end
Will need to define stuff for a lot of Lua libraries (see the work already done by TypedLua).
While we're talking about static analysis, what about forking luacheck into candrancheck? Or at least make the line mapping work.
Will require work.
* array slicing
local b = a[3:5:1]
is it actually useful? even in python I rarely use it, apart from extracting a row or column for a matrix (and we don't have >1D arrays in Lua so...)
OR return multiple value instead of a list?
or list of incices:
local a, b, c = l[1, 2, 3]
how to handle hash table?
local a, b, c = l.(a, b, c)
or
local a, b, c = l.a, .b, .c
but
local a, b, c = l[1], [2], [3]
conflicts with table comprehension: change or use .[n]?
or create some syntax akin to destructuring assignemnts but for numeric indexes:
local [a, b, c] = t
* Destructuring assignment
Allow recursive destructing assignements
* String interpolation
Delimited by ``:
`Hi, my name is ${@name}` -- -> "blaba" .. tostring(@name)
Also allows multi-line with this maybe?
meh
* Other potential inspiration
https://www.ruby-lang.org/
* Lua 5.4 stuff
const, to-be-closed variables: they're fun but as of now the syntax is awful