From 5b54c2c0505d37a6caccb49bf2c62d89a664a35a Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 5 May 2021 09:54:54 +0100 Subject: add arrays --- .../2010-05-09-the-fype-programming-language.html | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'content/html/gemfeed') 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; +

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

 (integer) defined <identifier>
@@ -378,6 +396,24 @@ func foo {
 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.:)

May the source be with you

-- cgit v1.2.3