diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-28 00:01:57 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-28 00:01:57 +0200 |
| commit | f5669d9677a6649be3a99fb0bb910b19d9f7bc51 (patch) | |
| tree | 956d341d78a0753374ab19fb928ae75368cec852 | |
| parent | b694c0423a7dfbdee1f957e8d2b06b5601e26a40 (diff) | |
Update content for md
26 files changed, 53 insertions, 3093 deletions
diff --git a/gemfeed/.rcmbackup/2008-06-26-perl-poetry.gmi.tpl.49f27f3f6cfb364dfb6ffe2de2faa0100ea27a3b5b8d237fb8934c293dfc74a9 b/gemfeed/.rcmbackup/2008-06-26-perl-poetry.gmi.tpl.49f27f3f6cfb364dfb6ffe2de2faa0100ea27a3b5b8d237fb8934c293dfc74a9 deleted file mode 100644 index bb16451a..00000000 --- a/gemfeed/.rcmbackup/2008-06-26-perl-poetry.gmi.tpl.49f27f3f6cfb364dfb6ffe2de2faa0100ea27a3b5b8d237fb8934c293dfc74a9 +++ /dev/null @@ -1,172 +0,0 @@ -# Perl Poetry - -> Published at 2008-06-26T21:43:51+01:00; Updated at 2021-05-04 - -Here are some Perl Poems I wrote. They don't do anything useful when you run them, but they don't produce a compiler error either. They only exist for fun and demonstrate what you can do with Perl syntax. - -Wikipedia: "Perl poetry is the practice of writing poems that can be compiled as legal Perl code, for example the piece known as Black Perl. Perl poetry is made possible by the large number of English words that are used in the Perl language. New poems are regularly submitted to the community at PerlMonks." - -=> https://en.wikipedia.org/wiki/Perl - -``` - '\|/' * --- * ----- - /|\ ____ - ' | ' {_ o^> * - : -_ /) - : ( ( .-''`'. - . \ \ / \ - . \ \ / \ - \ `-' `'. - \ . ' / `. - \ ( \ ) ( .') - ,, t '. | / | ( - '|``_/^\___ '| |`'-..-'| ( () -_~~|~/_|_|__/|~~~~~~~ | / ~~~~~ | | ~~~~~~~~ - -_ |L[|]L|/ | |\ MJP ) ) - ( |( / /| - ~~ ~ ~ ~~~~ | /\\ / /| | - || \\ _/ / | | - ~ ~ ~~~ _|| (_/ (___)_| |Nov291999 - (__) (____) -``` - -<< template::inline::toc - -## math.pl - -```perl -#!/usr/bin/perl - -# (C) 2006 by Paul C. Buetow - -goto library for study $math; -BEGIN { s/earching/ books/ -and read $them, $at, $the } library: - -our $topics, cos and tan, -require strict; import { of, tied $patience }; - -do { int'egrate'; sub trade; }; -do { exp'onentize' and abs'olutize' }; -study and study and study and study; - -foreach $topic ({of, math}) { -you, m/ay /go, to, limits } - -do { not qw/erk / unless $success -and m/ove /o;$n and study }; - -do { int'egrate'; sub trade; }; -do { exp'onentize' and abs'olutize' }; -study and study and study and study; - -grep /all/, exp'onents' and cos'inuses'; -/seek results/ for @all, log'4rithms'; - -'you' =~ m/ay /go, not home -unless each %book ne#ars -$completion; - -do { int'egrate'; sub trade; }; -do { exp'onentize' and abs'olutize' }; - -#at -home: //ig,'nore', time and sleep $very =~ s/tr/on/g; -__END__ - -``` - -## christmas.pl - -```perl -#!/usr/bin/perl - -# (C) 2006 by Paul C. Buetow - -Christmas:{time;#!!! - -Children: do tell $wishes; - -Santa: for $each (@children) { -BEGIN { read $each, $their, wishes and study them; use Memoize#ing - -} use constant gift, 'wrapping'; -package Gifts; pack $each, gift and bless $each and goto deliver -or do import if not local $available,!!! HO, HO, HO; - -redo Santa, pipe $gifts, to_childs; -redo Santa and do return if last one, is, delivered; - -deliver: gift and require diagnostics if our $gifts ,not break; -do{ use NEXT; time; tied $gifts} if broken and dump the, broken, ones; -The_children: sleep and wait for (each %gift) and try { to => untie $gifts }; - -redo Santa, pipe $gifts, to_childs; -redo Santa and do return if last one, is, delivered; - -The_christmas_tree: formline s/ /childrens/, $gifts; -alarm and warn if not exists $Christmas{ tree}, @t, $ENV{HOME}; -write <<EMail - to the parents to buy a new christmas tree!!!!111 - and send the -EMail -;wait and redo deliver until defined local $tree; - -redo Santa, pipe $gifts, to_childs; -redo Santa and do return if last one, is, delivered ;} - -END {} our $mission and do sleep until next Christmas ;} - -__END__ - -This is perl, v5.8.8 built for i386-freebsd-64int -``` - -## shopping.pl - -```perl -#!/usr/bin/perl - -# (C) 2007 by Paul C. Buetow - -BEGIN{} goto mall for $shopping; - -m/y/; mall: seek$s, cool products(), { to => $sell }; -for $their (@business) { to:; earn:; a:; lot:; of:; money: } - -do not goto home and exit mall if exists $new{product}; -foreach $of (q(uality rich products)){} package products; - -our $news; do tell cool products() and do{ sub#tract -cool{ $products and shift @the, @bad, @ones; - -do bless [q(uality)], $products -and return not undef $stuff if not (local $available) }}; - -do { study and study and study for cool products() } -and do { seek $all, cool products(), { to => $buy } }; - -do { write $them, $down } and do { order: foreach (@case) { package s } }; -goto home if not exists $more{money} or die q(uerying) ;for( @money){}; - -at:;home: do { END{} and:; rest:; a:; bit: exit $shopping } -and sleep until unpack$ing, cool products(); - -__END__ -This is perl, v5.8.8 built for i386-freebsd-64int -``` - -## More... - -Did you like what you saw? Have a look at Codeberg to see my other poems too: - -=> https://codeberg.org/snonux/perl-poetry - -E-Mail your comments to `paul@nospam.buetow.org` :-) - -Other related posts are: - -<< template::inline::rindex perl - -=> ../ Back to the main site diff --git a/gemfeed/.rcmbackup/2008-12-29-using-my-nokia-n95-for-fixing-my-mta.gmi.8f549e73479399b4d0e722c80728d34887bad242e066320ff17119682ffdf5d2 b/gemfeed/.rcmbackup/2008-12-29-using-my-nokia-n95-for-fixing-my-mta.gmi.8f549e73479399b4d0e722c80728d34887bad242e066320ff17119682ffdf5d2 deleted file mode 100644 index 33484e6c..00000000 --- a/gemfeed/.rcmbackup/2008-12-29-using-my-nokia-n95-for-fixing-my-mta.gmi.8f549e73479399b4d0e722c80728d34887bad242e066320ff17119682ffdf5d2 +++ /dev/null @@ -1,41 +0,0 @@ -# Using my Nokia N95 for fixing my MTA - -> Published at 2008-12-29T09:10:41+00:00; Updated at 2021-12-01 - -``` - - _ - |E] - .-|=====-. - | | mail | - ___|________| - || - || - || www - ,;, || )_(,;;;, - <_> \ || \|/ \_/ - \|/ \\|| \\| |// -_jgs_\|//_\\|///_\V/_\|//__ - Art by Joan Stark -``` - -The last week I was in Vidin, Bulgaria with no internet access and I had to fix my MTA (Postfix) at host.0.buetow.org which serves E-Mail for all my customers at P. B. Labs. Good, that I do not guarantee high availability on my web services (I've to do a full time job somewhere else too). - -My first attempt to find an internet café, which was working during Christmastime, failed. However, I found with my N95 phone lots of free WLAN hotspots. The hotspots refused me logging into my server using SSH as I have configured a non-standard port for SSH for security reasons. Without knowing the costs, I used the GPRS internet access of my German phone provider (yes, I had to pay roaming fees). - -=> ./using-my-nokia-n95-for-fixing-my-mta/nokia-n95.jpg Picture of a Nokia N95 - -With Putty for N95 and configuring Postfix with Vim and the T9 input mechanism, I managed to fix the problem. But it took half of an hour: - -* First, getting a shell prompt -* Second, use the "tail" command to analyse the Postfix logs -* Third, use the "sed" command to fix a syntax error in the Postfix config -* Fourth, restart Postfix - -It was a pain in the ass. My next mobile phone MUST have a full QWERTY keyboard. This would have made my life lots easier. :) - -At the moment I am in Sofia, Bulgaria. Here I can use at least an unprotected WLAN hotspot which belongs to one of the neighbours which I don’t know in person, and it is not blocking any port at all :) - -E-Mail your comments to `paul@nospam.buetow.org` :-) - -=> ../ Back to the main site diff --git a/gemfeed/.rcmbackup/2009-02-13-sgi-onyx-3200.gmi.e8c19f9d9486a1d74c8a1074d627e76fa9bf9aaa54d9dbd59a106a495c02c138 b/gemfeed/.rcmbackup/2009-02-13-sgi-onyx-3200.gmi.e8c19f9d9486a1d74c8a1074d627e76fa9bf9aaa54d9dbd59a106a495c02c138 deleted file mode 100644 index fd10c754..00000000 --- a/gemfeed/.rcmbackup/2009-02-13-sgi-onyx-3200.gmi.e8c19f9d9486a1d74c8a1074d627e76fa9bf9aaa54d9dbd59a106a495c02c138 +++ /dev/null @@ -1,68 +0,0 @@ -# SGI Onyx 3200 - -> Published at 2025-02-13T21:17:16+02:00 - -For nostalgia, I've kept this output of the 'dmesg' around. It's from an SGI Onyx 3200 graphics supercomputer running IRIX with the following specs: - -* 4 x 400 MHz IP35 MIPS CPUs -* 4GB of RAM - -=> ./sgi-onyx-3200/desk.webp - -We used this monster when I was a student worker at the Fraunhofer Institute for Production Technology around the year 2006. It operated a walk-in 2-sided 3D cave (unfortunately, I don't have any pictures of that cave), where you could literally walk around with a set of VR glasses and see everything in 3D (that was when there wasn't any Oculus Quest yet). That was useful for running industrial simulations. - -``` -4 400 MHZ IP35 Processors -CPU: MIPS R12000 Processor Chip Revision: 3.5 -FPU: MIPS R12010 Floating Point Chip Revision: 3.5 -Main memory size: 4096 Mbytes -Instruction cache size: 32 Kbytes -Data cache size: 32 Kbytes -Secondary unified instruction/data cache size: 8 Mbytes -Integral SCSI controller 8: Version Fibre Channel QL2200A -Integral SCSI controller 6: Version QL12160, single ended -Integral SCSI controller 7: Version QL12160, low voltage differential -Integral SCSI controller 9: Version IEEE1394 SBP2 - IEEE1394 CDROM: node 1010031001a454 port 0 on SCSI controller 9 -Integral SCSI controller 0: Version Fibre Channel QL2200A - Disk drive: unit 1 on SpCSI controller 0 - Disk drive: unit 2 on SCSI controller 0 -Integral SCSI controller 5: Version IEEE1394 SBP2 - IEEE1394 CDROM: node 1010031001c080 port 0 on SCSI controller 5 -IOC3 serial port: tty3 -IOC3 serial port: tty4 -IOC3 serial port: tty10 -IOC3 serial port: tty11 -IOC3 serial port: tty12 -IOC3 serial port: tty5 -IOC3 serial port: tty6 -IOC3 serial port: tty7 -IOC3 serial port: tty8 -IOC3 serial port: tty9 -Graphics board: InfiniteReality3 -Graphics board: InfiniteReality3 -Gigabit Ethernet: eg0, module 001c04, pci_bus 2, pci_slot 2, firmware version 12.4.10 -Fast Ethernet: ef1, version 1, module 001c07, pci 4 -Integral Fast Ethernet: ef0, version 1, module 001c04, pci 4 -Iris Audio Processor: version RAD revision 13.0, number 1 -IOC3 external interrupts: 2 -IOC3 external interrupts: 1 -IEEE 1394 High performance serial bus controller 0: Type: OHCI, Version 0 0 -IEEE 1394 High performance serial bus controller 1: Type: OHCI, Version 0 0 -USB controller: type OHCI -USB Human Interface Device: device id 1 type keyboard -USB Human Interface Device: device id 1 type mouse -USB controller: type OHCI -USB Human Interface Device: device id 0 type keyboard -USB Human Interface Device: device id 0 type mouse -``` - -=> ./sgi-onyx-3200/collage.webp - -I was mainly working on drilling simulations on this machine. Sometimes I worked directly at one of the 2 terminal screens of the Onyx, or often I used a nearby Linux machine and forwarded the X11 windows to my local screen. - -=> ./sgi-onyx-3200/collage2.webp - -E-Mail your comments to `paul@nospam.buetow.org` :-) - -=> ../ Back to the main site diff --git a/gemfeed/.rcmbackup/2010-04-09-standard-ml-and-haskell.gmi.tpl.94827a5494a2149e0e0f68d54010656f2fc707f8265377a801426e1e04351f3b b/gemfeed/.rcmbackup/2010-04-09-standard-ml-and-haskell.gmi.tpl.94827a5494a2149e0e0f68d54010656f2fc707f8265377a801426e1e04351f3b deleted file mode 100644 index a3d3ed79..00000000 --- a/gemfeed/.rcmbackup/2010-04-09-standard-ml-and-haskell.gmi.tpl.94827a5494a2149e0e0f68d54010656f2fc707f8265377a801426e1e04351f3b +++ /dev/null @@ -1,176 +0,0 @@ -# Standard ML and Haskell - -> Published at 2010-04-09T22:57:36+01:00 - -I am currently looking into the functional programming language Standard ML (aka SML). The purpose is to refresh my functional programming skills and to learn something new too. Since I already knew a little Haskell, I could not help myself, and I also implemented the same exercises in Haskell. - -As you will see, SML and Haskell are very similar (at least when it comes to the basics). However, the syntax of Haskell is a bit more "advanced". Haskell utilizes fewer keywords (e.g. no val, end, fun, fn ...). Haskell also allows to write down the function types explicitly. What I have been missing in SML so far is the so-called pattern guards. Although this is a very superficial comparison for now, so far, I like Haskell more than SML. Nevertheless, I thought it would be fun to demonstrate a few simple functions of both languages to show off the similarities. - -Haskell is also a "pure functional" programming language, whereas SML also makes explicit use of imperative concepts. I am by far not a specialist in either of these languages, but here are a few functions implemented in both SML and Haskell: - -<< template::inline::toc - -## Defining a multi-data type - -Standard ML: - -```sml -datatype ’a multi - = EMPTY - | ELEM of ’a - | UNION of ’a multi * ’a multi -``` - -Haskell: - -```haskell -data (Eq a) => Multi a - = Empty - | Elem a - | Union (Multi a) (Multi a) - deriving Show -``` - -## Processing a multi - -Standard ML: - -```sml -fun number (EMPTY) _ = 0 - | number (ELEM x) w = if x = w then 1 else 0 - | number (UNION (x,y)) w = (number x w) + (number y w) -fun test_number w = number (UNION (EMPTY, \ - UNION (ELEM 4, UNION (ELEM 6, \ - UNION (UNION (ELEM 4, ELEM 4), EMPTY))))) w -``` - -Haskell: - -```haskell -number Empty _ = 0 -number (Elem x) w = if x == w then 1 else 0 -test_number w = number (Union Empty \ - (Union (Elem 4) (Union (Elem 6) \ - (Union (Union (Elem 4) (Elem 4)) Empty)))) w -``` - -## Simplify function - -Standard ML: - -```sml -fun simplify (UNION (x,y)) = - let fun is_empty (EMPTY) = true | is_empty _ = false - val x’ = simplify x - val y’ = simplify y - in if (is_empty x’) andalso (is_empty y’) - then EMPTY - else if (is_empty x’) - then y’ - else if (is_empty y’) - then x’ - else UNION (x’, y’) - end - | simplify x = x -``` - -Haskell: - -```haskell -simplify (Union x y) - | (isEmpty x’) && (isEmpty y’) = Empty - | isEmpty x’ = y’ - | isEmpty y’ = x’ - | otherwise = Union x’ y’ - where - isEmpty Empty = True - isEmpty _ = False - x’ = simplify x - y’ = simplify y -simplify x = x -``` - -## Delete all - -Standard ML: - -```sml -fun delete_all m w = - let fun delete_all’ (ELEM x) = if x = w then EMPTY else ELEM x - | delete_all’ (UNION (x,y)) = UNION (delete_all’ x, delete_all’ y) - | delete_all’ x = x - in simplify (delete_all’ m) - end -``` - -Haskell: - -```haskell -delete_all m w = simplify (delete_all’ m) - where - delete_all’ (Elem x) = if x == w then Empty else Elem x - delete_all’ (Union x y) = Union (delete_all’ x) (delete_all’ y) - delete_all’ x = x -``` - -## Delete one - -Standard ML: - -```sml -fun delete_one m w = - let fun delete_one’ (UNION (x,y)) = - let val (x’, deleted) = delete_one’ x - in if deleted - then (UNION (x’, y), deleted) - else let val (y’, deleted) = delete_one’ y - in (UNION (x, y’), deleted) - end - end - | delete_one’ (ELEM x) = - if x = w then (EMPTY, true) else (ELEM x, false) - | delete_one’ x = (x, false) - val (m’, _) = delete_one’ m - in simplify m’ - end -``` - -Haskell: - -```haskell -delete_one m w = do - let (m’, _) = delete_one’ m - simplify m’ - where - delete_one’ (Union x y) = - let (x’, deleted) = delete_one’ x - in if deleted - then (Union x’ y, deleted) - else let (y’, deleted) = delete_one’ y - in (Union x y’, deleted) - delete_one’ (Elem x) = - if x == w then (Empty, True) else (Elem x, False) - delete_one’ x = (x, False) -``` - -## Higher-order functions - -The first line is always the SML code, the second line the Haskell variant: - -``` -fun make_map_fn f1 = fn (x,y) => f1 x :: y -make_map_fn f1 = \x y -> f1 x : y - -fun make_filter_fn f1 = fn (x,y) => if f1 x then x :: y else y -make_filter_fn f1 = \x y -> if f1 then x : y else y - -fun my_map f l = foldr (make_map_fn f) [] l -my_map f l = foldr (make_map_fn f) [] l - -fun my_filter f l = foldr (make_filter_fn f) [] l -my_filter f l = foldr (make_filter_fn f) [] l -``` - -E-Mail your comments to `paul@nospam.buetow.org` :-) - -=> ../ Back to the main site diff --git a/gemfeed/.rcmbackup/2010-05-07-lazy-evaluation-with-standard-ml.gmi.f3bdd7120c249354bf0503c9ed61a11918e2db7b75fa0bd93a5b7402d87cce43 b/gemfeed/.rcmbackup/2010-05-07-lazy-evaluation-with-standard-ml.gmi.f3bdd7120c249354bf0503c9ed61a11918e2db7b75fa0bd93a5b7402d87cce43 deleted file mode 100644 index 738d54a8..00000000 --- a/gemfeed/.rcmbackup/2010-05-07-lazy-evaluation-with-standard-ml.gmi.f3bdd7120c249354bf0503c9ed61a11918e2db7b75fa0bd93a5b7402d87cce43 +++ /dev/null @@ -1,102 +0,0 @@ -# Lazy Evaluation with Standard ML - -> Published at 2010-05-07T08:17:59+01:00 - -``` - - _____|~~\_____ _____________ - _-~ \ | \ - _- | ) \ |__/ \ \ - _- ) | | | \ \ - _- | ) / |--| | | - __-_______________ /__/_______| |_________ -( |---- | | - `---------------'--\\\\ .`--' -Glyde- - `|||| -``` - -In contrast to Haskell, Standard SML does not use lazy evaluation by default but an eager evaluation. - -=> https://en.wikipedia.org/wiki/Eager_evaluation -=> https://en.wikipedia.org/wiki/Lazy_evaluation - - -You can solve specific problems with lazy evaluation easier than with eager evaluation. For example, you might want to list the number Pi or another infinite list of something. With the help of lazy evaluation, each element of the list is calculated when it is accessed first, but not earlier. - -## Emulating lazy evaluation in SML - -However, it is possible to emulate lazy evaluation in most eager evaluation languages. This is how it is done with Standard ML (with some play with an infinite list of natural number tuples filtering out 0 elements): - -``` -type ’a lazy = unit -> ’a; - -fun force (f:’a lazy) = f (); -fun delay x = (fn () => x) : ’a lazy; - -datatype ’a sequ = NIL | CONS of ’a * ’a sequ lazy; - -fun first 0 s = [] - | first n NIL = [] - | first n (CONS (i,r)) = i :: first (n-1) (force r); - -fun filters p NIL = NIL - | filters p (CONS (x,r)) = - if p x - then CONS (x, fn () => filters p (force r)) - else - filters p (force r); - -fun nat_pairs () = - let - fun from_pair (x,0) = - CONS ((x,0), fn () => from_pair (0,x+1)) - | from_pair (up,dn) = - CONS ((up,dn), fn () => from_pair (up+1,dn-1)) - in from_pair (0,0) - end; - -(* Test -val test = first 10 (nat_pairs ()) -*) - -fun nat_pairs_not_null () = - filters (fn (x,y) => x > 0 andalso y > 0) (nat_pairs ()); - -(* Test -val test = first 10 (nat_pairs_not_null ()); -*) -``` - -=> http://smlnj.org/ - -## Real laziness with Haskell - -As Haskell already uses lazy evaluation by default, there is no need to construct a new data type. Lists in Haskell are lazy by default. You will notice that the code is also much shorter and easier to understand than the SML version. - -``` -{- Just to make it look like the ML example -} -first = take -filters = filter - -{- Implementation -} -nat_pairs = from_pair 0 0 - where - from_pair x 0 = [x,0] : from_pair 0 (x+1) - from_pair up dn = [up,dn] : from_pair (up+1) (dn-1) - -{- Test: -first 10 nat_pairs --} - -nat_pairs_not_null = filters (\[x,y] -> x > 0 && y > 0) nat_pairs - -{- Test: -first 10 nat_pairs_not_null --} -``` - -=> http://www.haskell.org/ - -E-Mail your comments to `paul@nospam.buetow.org` :-) - -=> ../ Back to the main site diff --git a/gemfeed/.rcmbackup/2010-05-09-the-fype-programming-language.gmi.tpl.9797b465fab8bb78c39245ea4138babc12364c18bb386e7d7543fc61b8b529dc b/gemfeed/.rcmbackup/2010-05-09-the-fype-programming-language.gmi.tpl.9797b465fab8bb78c39245ea4138babc12364c18bb386e7d7543fc61b8b529dc deleted file mode 100644 index 683e2357..00000000 --- a/gemfeed/.rcmbackup/2010-05-09-the-fype-programming-language.gmi.tpl.9797b465fab8bb78c39245ea4138babc12364c18bb386e7d7543fc61b8b529dc +++ /dev/null @@ -1,512 +0,0 @@ -# The Fype Programming Language - -> Published at 2010-05-09T12:48:29+01:00; Updated at 2021-05-05 - -Fype is an interpreted programming language created by me for learning and fun. The interpreter is written in C. It has been tested on FreeBSD and NetBSD and may also work on other Unix like operating systems such as Linux based ones. Besides learning and fun, there is no other use case of why Fype exists as many other programming languages are much faster and more powerful. - -The Fype syntax is straightforward and uses a maximum look ahead of 1 and an effortless top-down parsing mechanism. Fype is parsing and interpreting its code simultaneously. This means that syntax errors are only detected during program runtime. - -Fype is a recursive acronym and means "Fype is For Your Program Execution" or "Fype is Free Yak Programmed for ELF". You could also say, "It's not a hype - it's Fype!". - -``` - ____ _ __ - / / _|_ _ _ __ ___ _ _ ___ __ _| |__ / _|_ _ - / / |_| | | | '_ \ / _ \ | | | |/ _ \/ _` | '_ \ | |_| | | | - _ / /| _| |_| | |_) | __/ | |_| | __/ (_| | | | |_| _| |_| | -(_)_/ |_| \__, | .__/ \___| \__, |\___|\__,_|_| |_(_)_| \__, | - |___/|_| |___/ |___/ -``` - -<< template::inline::toc - -## Object-oriented C style - -The Fype interpreter is written in an object-oriented style of C. Each "main component" has its own .h and .c file. There is a struct type for each (most components at least) component, which can be initialized using a "COMPONENT_new" function and destroyed using a "COMPONENT_delete" function. Method calls follow the same schema, e.g. "COMPONENT_METHODNAME". There is no such as class inheritance and polymorphism involved. - -To give you an idea of how it works here as an example is a snippet from the main Fype "class header": - -```c -typedef struct { - Tupel *p_tupel_argv; // Contains command line options - List *p_list_token; // Initial list of token - Hash *p_hash_syms; // Symbol table - char *c_basename; -} Fype; -``` - -And here is a snippet from the primary Fype "class implementation": - -```c -Fype* -fype_new() { - Fype *p_fype = malloc(sizeof(Fype)); - - p_fype->p_hash_syms = hash_new(512); - p_fype->p_list_token = list_new(); - p_fype->p_tupel_argv = tupel_new(); - p_fype->c_basename = NULL; - - garbage_init(); - - return (p_fype); -} - -void -fype_delete(Fype *p_fype) { - argv_tupel_delete(p_fype->p_tupel_argv); - - hash_iterate(p_fype->p_hash_syms, symbol_cleanup_hash_syms_cb); - hash_delete(p_fype->p_hash_syms); - - list_iterate(p_fype->p_list_token, token_ref_down_cb); - list_delete(p_fype->p_list_token); - - if (p_fype->c_basename) - free(p_fype->c_basename); - - garbage_destroy(); -} - -int -fype_run(int i_argc, char **pc_argv) { - Fype *p_fype = fype_new(); - - // argv: Maintains command line options - argv_run(p_fype, i_argc, pc_argv); - - // scanner: Creates a list of token - scanner_run(p_fype); - - // interpret: Interpret the list of token - interpret_run(p_fype); - - fype_delete(p_fype); - - return (0); -} -``` - -## Data types - -Fype uses auto type conversion. However, if you want to know what's going on, you may take a look at the following basic data types: -* integer - Specifies a number -* double - Specifies a double-precision number -* string - Specifies a string -* number - May be an integer or a double number -* any- May be any type above -* void - No type -* identifier - It's a variable name or a procedure name, or a function name - -There is no boolean type, but we can use the integer values 0 for false and 1 for true. There is support for explicit type casting too. - -## Syntax - -### Comments - -Text from a # character until the end of the current line is considered being a comment. Multi-line comments may start with an #* and with a *# anywhere. Exceptions are if those signs are inside of strings. - -### Variables - -Variables are defined with the "my" keyword (inspired by Perl :-). If you don't assign a value during declaration, it uses the default integer value 0. Variables may be changed during program runtime. Variables may be deleted using the "undef" keyword! Example: - -``` -my foo = 1 + 2; -say foo; - -my bar = 12, baz = foo; -say 1 + bar; -say bar; - -my baz; -say baz; # Will print out 0 -``` - -You may use the "defined" keyword to check if an identifier has been defined or not: - -``` -ifnot defined foo { - say "No foo yet defined"; -} - -my foo = 1; - -if defined foo { - put "foo is defined and has the value "; - say foo; -} -``` - -### Synonyms - -Each variable can have as many synonyms as wished. A synonym is another name to access the content of a specific variable. Here is an example of how to use it: - -``` -my foo = "foo"; -my bar = \foo; -foo = "bar"; - -# The synonym variable should now also set to "bar" -assert "bar" == bar; -``` - -Synonyms can be used for all kind of identifiers. It's not limited to standard variables but can also be used for function and procedure names (more about functions and procedures later). - -``` -# Create a new procedure baz -proc baz { say "I am baz"; } - -# Make a synonym baz, and undefine baz -my bay = \baz; - -undef baz; - -# bay still has a reference of the original procedure baz -bay; # this prints aut "I am baz" -``` - -The "syms" keyword gives you the total number of synonyms pointing to a specific value: - -``` -my foo = 1; -say syms foo; # Prints 1 - -my baz = \foo; -say syms foo; # Prints 2 -say syms baz; # Prints 2 - -undef baz; -say syms foo; # Prints 1 -``` - -## Statements and expressions - -A Fype program is a list of statements. Each keyword, expression or function call is part of a statement. Each statement is ended with a semicolon. Example: - -``` -my bar = 3, foo = 1 + 2; -say foo; -exit foo - bar; -``` - -### Parenthesis - -All parenthesis for function arguments is optional. They help to |
