From 14f08d0c340c4dc20ef256e8c8dbe925ae600c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Przemys=C5=82aw=20Pluta?= Date: Sun, 22 Mar 2020 00:00:11 +0100 Subject: [PATCH] Created About SMNP Language (markdown) --- About-SMNP-Language.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 About-SMNP-Language.md diff --git a/About-SMNP-Language.md b/About-SMNP-Language.md new file mode 100644 index 0000000..2b0ba6e --- /dev/null +++ b/About-SMNP-Language.md @@ -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. \ No newline at end of file