kailua
kailua copied to clipboard
Documentation requests
The following is a (incomplete) list of collected issues or deficiencies (that is, documented but not very visible) on the current language documentation. Some of them are directly related to the language shortcoming as well. Short answers are provided.
- [ ] How does
WHATEVER
differ fromany
?WHATEVER
ignores the checking whileany
will be no way usable in the checking. By usingany
you force the usage ofassume
(which is safer thanWHATEVER
). - [ ] How can I specify types for variadic arguments? Using
string.format
as an example:--v function(fmt: string, ...: any) --> string
, or... --: any
on the declaration. Note the symmetry. - [ ] Why can't I omit
any
argument? It will accept an explicitnil
value but you needany?
to omit any arguments. - [ ] How can I use union types?
T | U
. You will need--# assume
to destructure it. - [ ] How can I use nilable types?
T?
. You can explicitly assign it toT
, or--# assume
to get rid of nil. - [ ] How can I use "modules"? Any table can be declared with
--: module
to enable the delayed type checking against its methods. - [ ] Can I use
--: module
against classes? Yes, e.g.SomeClass = class() --: module
. - [ ] How can I use
[make_class]
? Normally via--# assume
. You can also use[make_class]
with[NO_CHECK]
functions. The resulting function should be appropriately typed (currentlyfunction() --> any
). - [ ] How can I represent the lack of return type?
--> ()
or use--v
form. (When--v
is not in use, the missing return type will be inferred.) If your function never returns, use--> !
. - [ ] How can I specify types for each fields in the table? Currently you need to use the whole type for the entire table:
a = { x = 1, y = 2 } --: { x: integer, y: integer }
.