Created About SMNP Language (markdown)

Bartłomiej Przemysław Pluta
2020-03-22 00:00:11 +01:00
parent 25812af343
commit 14f08d0c34

31
About-SMNP-Language.md Normal file

@@ -0,0 +1,31 @@
SMNP language is interpreted, high-level, formal language with syntax mostly inspired by Java language with - according to Chomsky's hierarchy - _context-free grammar_.
The language is designed to make writing music easy and straightforward and to reduce unnecessary
boilerplate when typing notes by simply adapting general purpose languages' syntax and introducing new syntax constructs, including i.e. note literal or staff syntax.
# Type system
SMNP is dynamic language, because there are no any static analyzer between
parsing and evaluating stages. It means that any type-mismatching
will be raised on runtime, when control flow reaches the point of error.
For example:
```
function foo(n: int) {
println(n);
}
x = false;
if (x) {
foo("hello");
}
```
As long as `x == false`, the code will be executed without any errors,
even though `foo` function expects integer argument and is being called
with string.
However, if you switch `x` value to `true`, error will be thrown when
control flow reaches `foo` function invocation with wrong argument's type.
Even though there is no real definition of strongly-typed language,
we can say SMNP is strongly-typed, because there are no any implicit type
coercion. You always have to provide correct, expected type.