diff options
| author | Paul Buetow <git@mx.buetow.org> | 2021-05-05 09:54:54 +0100 |
|---|---|---|
| committer | Paul Buetow <git@mx.buetow.org> | 2021-05-21 05:11:04 +0100 |
| commit | 5b54c2c0505d37a6caccb49bf2c62d89a664a35a (patch) | |
| tree | 83163e249e732e9221ff51fc30c812d2a27e2b65 | |
| parent | 7e3ea4708943765b9c38067a08a942776494f838 (diff) | |
add arrays
| -rw-r--r-- | content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi | 43 | ||||
| -rw-r--r-- | content/html/gemfeed/2010-05-09-the-fype-programming-language.html | 36 |
2 files changed, 79 insertions, 0 deletions
diff --git a/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi b/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi index 74a6c259..9aa3b675 100644 --- a/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi +++ b/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi @@ -305,6 +305,26 @@ my foo = 1; say defined bar; ``` +Another example including an actual output: + +``` +./fype -e ’my global; func foo { my var4; func bar { my var2, var3; func baz { my var1; scope; } baz; } bar; } foo;’ +Scopes: +Scope stack size: 3 +Global symbols: +SYM_VARIABLE: global (id=00034, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1) +SYM_FUNCTION: foo +Local symbols: +SYM_VARIABLE: var1 (id=00038, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1) +1 level(s) up: +SYM_VARIABLE: var2 (id=00036, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1) +SYM_VARIABLE: var3 (id=00037, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1) +SYM_FUNCTION: baz +2 level(s) up: +SYM_VARIABLE: var4 (id=00035, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1) +SYM_FUNCTION: bar +``` + ## Definedness ``` @@ -455,6 +475,29 @@ foo; bar; # Will produce an error, because bar is out of scope! ``` +## Arrays + +Some progress on arrays has been made too. The following example creates a multi dimensional array "foo". Its first element is the return value of the func which is 0. The fourth value is a string ”3” converted to a double number. The last element is an anonymous array which itself contains another anonymous array as its last element: + +``` +func bar { say ”bar” } +my foo = [bar, 1, 4/2, double ”3”, [”A”, [”BA”, ”BB”]]]; +say foo; +``` + +It produces the following output: + +``` +% ./fype arrays.fy +bar +01 +2 +3.000000 +A +BA +BB +``` + ## Fancy stuff Fancy stuff like OOP or Unicode or threading is not planed. But fancy stuff like function pointers and closures may be considered.:) diff --git a/content/html/gemfeed/2010-05-09-the-fype-programming-language.html b/content/html/gemfeed/2010-05-09-the-fype-programming-language.html index 40beea42..5dd8e5e0 100644 --- a/content/html/gemfeed/2010-05-09-the-fype-programming-language.html +++ b/content/html/gemfeed/2010-05-09-the-fype-programming-language.html @@ -265,6 +265,24 @@ my foo = 1; # Prints out 0 say defined bar; </pre> +<p>Another example including an actual output:</p> +<pre> +./fype -e ’my global; func foo { my var4; func bar { my var2, var3; func baz { my var1; scope; } baz; } bar; } foo;’ +Scopes: +Scope stack size: 3 +Global symbols: +SYM_VARIABLE: global (id=00034, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1) +SYM_FUNCTION: foo +Local symbols: +SYM_VARIABLE: var1 (id=00038, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1) +1 level(s) up: +SYM_VARIABLE: var2 (id=00036, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1) +SYM_VARIABLE: var3 (id=00037, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1) +SYM_FUNCTION: baz +2 level(s) up: +SYM_VARIABLE: var4 (id=00035, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1) +SYM_FUNCTION: bar +</pre> <h2>Definedness </h2> <pre> (integer) defined <identifier> @@ -378,6 +396,24 @@ func foo { foo; bar; # Will produce an error, because bar is out of scope! </pre> +<h2>Arrays</h2> +<p>Some progress on arrays has been made too. The following example creates a multi dimensional array "foo". Its first element is the return value of the func which is 0. The fourth value is a string ”3” converted to a double number. The last element is an anonymous array which itself contains another anonymous array as its last element:</p> +<pre> +func bar { say ”bar” } +my foo = [bar, 1, 4/2, double ”3”, [”A”, [”BA”, ”BB”]]]; +say foo; +</pre> +<p>It produces the following output:</p> +<pre> +% ./fype arrays.fy +bar +01 +2 +3.000000 +A +BA +BB +</pre> <h2>Fancy stuff</h2> <p>Fancy stuff like OOP or Unicode or threading is not planed. But fancy stuff like function pointers and closures may be considered.:) </p> <h2>May the source be with you</h2> |
