Recently in Fype Category

Redesign of the Fype Interpreter

| No Comments | No TrackBacks

fype_small.pngAfter reading Structure and Interpretation of Computer Programs I decided to rethink the interpreter of Fype. Fype is a small scripting language invented and implemented (in C) by me. I decided to take the code-base of Fype and to rewrite the core of its interpreter-part in order to use a Scheme/Lisp-like syntax. which is much easier to parse. The syntax is simpler and much more powerful now. So far it is now possible to define functions and sub-functions and to display all involving frames. Here is an example:

(def (test)
   (say "This is test")
   (def (test2) 
      (say "I am in test2" "And test3 will be defined next!")
      (def (test3)
         (say "Displaying all frames now:")
         (show-frames))
      (test3))
   (test2))
(test)

The invocation of the interpreter prints out the following result:

This is test
I am in test2
And test3 will be defined next!
Displaying all frames now:
FRAME(id=3) 0:
FRAME(id=2) 1:
+ST_LAMBDA(name=test3;args=)
( ( say Displaying all frames now: ) ( show-frames ) )
FRAME(id=1) 2:
+ST_LAMBDA(name=test2;args=)
( ( say I am in test2 And test3 will be defined next! ) ( def ( test3 ) ( say Displaying all frames now: ) ( show-frames ) ) ( test3 ) )
FRAME(id=0) 3:
+ST_LAMBDA(name=test;args=)
( ( say This is test ) ( def ( test2 ) ( say I am in test2 And test3 will be defined next! ) ( def ( test3 ) ( say Displaying all frames now: ) ( show-frames ) ) ( test3 ) ) ( test2 ) )

Now what's left to do: Implement a few more built in functions. And we have a new Scheme/Lisp-like language with a very very small footprint available :)

Btw.: This version of fype aims to be pure-functional and with lazy evaluation.

41VPCK8QCXL._SS500_.jpgDuring Christmas break I read the book "Structure and Interpretation of Computer Programs - Second Edition" (by Harald Abelson and Garald Jay Sussman with Julie Sussman).

"The book should be read by every self-respecting computer scientist. Because of its clarity, simplicity, and wit, this work is highly recommended to anyone seeking an understanding of the emerging pradigms of computer science"

-- Mitchell Wand, American Scientist

This book handles all the topics using the dialect of Lisp called Scheme. It is impressive how simple a syntax and the interpreter and how powerfull the corresponding language can be. The book is mainly dealing with funcional programming techniques. I should overthink Fype, which is my own language for which I wrote an interpreter for.

fype.org expires

| No Comments | No TrackBacks

The following domain name(s) will expire in 5 DAYS:

Domain Name, Expiry Date
fype.org, 2008-12-03

Soon, all my domains except of buetow.org and pb-labs.com have been expired :D

fype.org's new address is fype.buetow.org. Subdomains ftw :)

Arrays Progress

| No Comments | No TrackBacks

Tonight I made the first real step in using Arrays in Fype. It is now possible to create arrays (even anonymous ones, which are used for multidimensional arrays). Here is an example:

# Create a function bar, it returns 0 by default
func bar { say "bar" }

# Create 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 has another anonymous array
# as its last element.
my foo = [bar, 1, 4/2, double "3", ["A", ["BA", "BB"]]];

# Run on each element of foo recursively the function 'say'
say foo;

It produces the following output:
% ./fype test.fy
bar
0
1
2
3.000000
A
BA
BB

The next step will be array operations such as accessing single elements of an array or to add/remove or modify the elements.

Ideas for References in Fype

| No Comments | No TrackBacks

Hello world!

In order to implement Arrays in Fype I need to have References in Fype. E.g. if I want to have multi dimensional Arrays, they should behave in contrast to Perl 5 like this:

# two-dimensional array in Perl, the programer has
# to tell explicitly to use references:
my @foo = (1, 2);
my @multi = (\@foo, [3, 4]);
print $multi[0][1]; # Prints out 2
my $bar = 'bar';
my $ref = \$bar;
print $$ref; # Prints out 'bar'

# In Fype it could look like this, all array elements
# are automatically references:
my foo = [1 2];
my multi = [foo [3 4]];
put multi[0][1]; # Prints out 2
my bar = "bar";
my ref = &bar;
put *ref; # Prints out 'bar'

As you can see, Fype will probably use & and * for the reference- and de-reference operators. Or do you have a better suggestion?

Monitoring Scopes in Fype

| No Comments | No TrackBacks

I recently added the "scope" function to Fype. scope can be called at any time from a Fype program. It prints all symbols which are available at the current scope to stdout.

For example if I run the following one liner:

./fype -e 'my global; func foo { my var4; func bar { my var2, var3; func baz { my var1; scope; } baz; } bar; } foo;'

Then, the output will look like this:

Scopes:
Scope stack size: 3
Global symbols:
SYM_VARIABLE: global (id=00034, line=-0001, pos=-001, type=TT_INTEGER, val=(null), ival=0, dval=0.000000, refs=-1)
SYM_FUNCTION: foo
Local symbols:
SYM_VARIABLE: var1 (id=00038, line=-0001, pos=-001, type=TT_INTEGER, val=(null), ival=0, dval=0.000000, refs=-1)
1 level(s) up:
SYM_VARIABLE: var2 (id=00036, line=-0001, pos=-001, type=TT_INTEGER, val=(null), ival=0, dval=0.000000, refs=-1)
SYM_VARIABLE: var3 (id=00037, line=-0001, pos=-001, type=TT_INTEGER, val=(null), ival=0, dval=0.000000, refs=-1)
SYM_FUNCTION: baz
2 level(s) up:
SYM_VARIABLE: var4 (id=00035, line=-0001, pos=-001, type=TT_INTEGER, val=(null), ival=0, dval=0.000000, refs=-1)
SYM_FUNCTION: bar

It backtraces all scopes at the point "scope" gets called. This helps debugging scopes in fype if needed.

Redesign of Fype's Garbage Collector

| No Comments | No TrackBacks

Fype needs a better garbage collector. I've implemented a garbage collector half a year ago for Fype, however many things have changed in the source and I lost the overview a little bit. The new garbage collector should be:

- Easy to use
- Easy to extend
- Easy to monitor

Synonyms in Fype

| No Comments | No TrackBacks

I've implemented synonyms for Fype.

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 synomyms:

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 normal variables but can be also used for function and procedure names etc. Here is yet another example:

# 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"

assert 0 == defined baz;
assert 1 == defined bay;

# This removes the procedure from memory
undef bay;

Having fun debugging Fype

| 4 Comments | No TrackBacks

fype.png Do you know days you only spend time debugging code and learning more and more advanced stuff like how to debug code (e.g. w/ GDB)? After starting implementing arrays in Fype I somehow screwed up the garbage collector. After fixing the GC I broke somehow scope.c (which is used to handle scopeing of variables within Fype scripts). After ~2 days of debugging I rolled back from revision 207 to 202 (now revision 208) and I'll start implementing arrays new from scratch. Probably I first should implement reference variables first in Fype. Array elements should be always references. Those should be handled differently by the GC.

DTrace for FreeBSD

| No Comments | No TrackBacks

Recently I upgraded my laptop (ThinkPad T42) to FreeBSD 7.1-PRERELEASE:

chuck% uname -a
FreeBSD chuck.lan.buetow.org 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #4: Mon Oct 13 19:47:52 UTC 2008 root@chuck.lan.buetow.org:/usr/obj/mnt/srcs/freebsd.src7/src/sys/JOGHURT7 i386
chuck% which dtrace
/usr/sbin/dtrace

:-)

Soon I'll test dtrace on Fype. Fype 0.1 still has some issues (garbage collector bugs) and those have to get fixed before the first release!

Fype is now in a Dictionary

| No Comments | No TrackBacks

At The Free Dictionary is now an entry which tells that FYPE is Free Yak Programmed for ELF! :) Fype may also be For Your Program Execution!

Fype is a scripting language being developed (in C99) by myself just for fun!

Plan for Arrays in Fype

| 1 Comment | 2 TrackBacks

I am in vacation in Valencia, Spain and after I finished reading all my magazines on the beach and after going swimming a lot I felt boring and prepared a small sheet w/ how Fypes arrays will look like. I think I'll start implementing on my way back home to Germany! I wrote this @ the beach, so please excuse the bad handwriting style :)

fype-arrays-plan.jpg

Mega screenshot (Update)

| No Comments | No TrackBacks

Here is a mega screenshot of my new configured Xinerama (TwinView) desktop using a total screen resolution of 3520x1200 (1600x1200 CRT + 1920x1200 TFT). The X Window System is running the FVWM2-devel as its window manager. I am using xcompmgr for transparent windows and window shadows. The GVim editor is using a C function browser plugin, as well as code omni completion, tabbing, split screening, code navigation etc.! And it is running on FreeBSD 7.0-RC2 :) Btw.: This is how it looks like if I program on Fype!

2008-02-21-190801_3520x1200_scrot.png

Update: Embedded screenshot perview into this post

About this Archive

This page is an archive of recent entries in the Fype category.

Fun is the previous category.

Games is the next category.

Find recent content on the main index or look in the archives to find all content.