First, let’s provide some context.
I do not find void type useful. Therefore, void == null.
Now, let’s state all cases when null appears:
?.
operator.Not many cases to consider, only last one is the meaningful one. It
is important to throw exceptions for not found properties, because it
might be a typo. Typos are hard to find. ?.
operator exists
if user intentionally wants to ignore non-existing property. This is
very useful to write concise code. Without ?.
we have to
write something like this:
// Say, want to check if svgArgs in a exist.
// Then do some operations with them.
if(a.properties.has("svgArgs")) {...} // without ?.
if(a?.svgArgs != 0) {...} // with ?.
...
// Better example:
class A {
= if(parent == 0) 1 else parent.iter + 1 // without ?.
iter = parent?.iter + 1 // with ?.
iter }
First example has a problem: when using ?.
we can’t
really differentiate whether a
has a property
svgArgs
which value is 0, or a
does not have
such property. However, I think it is an issue only in a language where
null as a no-reference exists.
The answer to this question is:
Embedded functions are functions that are translated from kotlin. All global functions and type functions are embedded. Here is an implementation of global functions (GitHub).
It seems natural for me to shorten embedded functions quantity as much as possible (and write them in created language2). I had three reasons to add many:
log
, write
and read
functions access lower-level APIs that are impossible to define in a
language itself (at least not in mine).Symbol table is a common idea in language processing, it goes hand in hand with scopes.
Symbol table is a solution to three concerns:
It is organized as three tables:
SymbolTable is a God-manager, but it is needed to handle all get requests (get function, get variable, etc).
Strings are keys for each map. Each string is a name for corresponding variable/type/function. It solves third problem and makes sharing reference-type values between variables straightforward, unlike storing name in a variable class3 (how to store multiple names? When to remove a name? etc.).
Probably I will remove parent
property for
non-class instances. I don’t remember why this feature exists.
Nevertheless, it is too early to remove without giving it proper
thought.↩︎
At least to see how well language works.↩︎
At first I implemented this design. Then I created SymbolTable and had many refactorings before finally decomposing it into three different classes-tables.↩︎