Recently in C/C++ 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.

No, this is not going to be a Windows cetric blog. But I want to mention, that I hate Windows and Windows hates me!

For $money I developed a TCP/IP server application in C which should run in background (without having a DOS window in the foreground). It would have been so easy if it'd be like on almost all other operating systems: nohup ./yourprogram &

On Windows XP you need to extend your C application in order to support Windows Services. In order to support Windows Services, you need to write about 50 more LOC. And it is frustrating to find out how to change the working directory of your own Windows Service. The standard working directory is c:\WINDOWS\system32. I managed doing so in reading an optional parameter (which is editable in the Windows Registry [uargh, why not under the Windows Service options?]) and to use the SetCurrentDirectory function of the WinAPI. Whah, yet another nasty thing about Windows: The function name SetCurrentDirectory starts with a capital letter, which is against my own coding conventions ;)

After all, everything is now running as expected! And without Cygwin it almost would have been mission impossible!

I do not like Windows ;)

Formatting C Code

| 1 Comment | No TrackBacks
Use the following Code in your Makefile and use "make style" and get your C code formatted.  It will also prove that no  source line is longer than 80 chars. It will print a notice if more than 80 chars per line are reached and it will also print the affected filenames and line numbers. This script needs to have astyle installed and it has been tested on FreeBSD with pmake but not with GNU Make. You may need to modify the script if you are going to use Linux w/ GNU Make.

 style: astyle check
 astyle:
     find ./src -name '*.[ch]' -exec sh -c 'astyle -s3 {}; rm -f {}.orig' \;
 check:
     for f in `find ./src -name '*.[ch]'`; do awk -v f=$$f \
         '{ if (length($$0) > 80) { \
         printf "Max line length reached @ %s:%d => %d\n", \
         f, NR, length($$0) } }' $$f; done

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.

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 C/C++ category.

buetow.org is the previous category.

CCC is the next category.

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