Name: Anonymous 2012-01-28 22:31
I have been using Chicken for a little bit. Used Racket for like 5 minutes. R6RS is PIG DISGUSTING!
That is all.
That is all.
typedef struct object {
int type;
union {
struct {
object *car;
object *cdr;
} pair;
char *symbol;
char *string;
double number; /* or implement bignums if you want */
...
} val;
} object;cons, car, cdr, symbol, string, number, etc. and you're ready to the write the parser.chars or a FILE stream) and returns a tree (of objects) that represent the code as data. display concurrently so you can have display(parse(stdin)); in your main loop until the parser is completed. Once the output is equivalent to the input, you're ready to move on. eval. Once you have your generic Scheme object and all the necessary primitive-like constructors, predicates, accessors and mutators, you could translate the metacircular evaluator from SICP to C in a few hours. The MCE is not that elegant, however, and will certainly be slow as balls. The way it stores the environment for instance is too complex and can be greatly simplified. Primitive and compound procedures are better represented as native C structs contained in object rather than "tagged lists". MCE's eval however is a good starting point for learning how to implement the define, lambda, and if special forms. apply. Binding primitives to your application will be time consuming and tedious, but it's rewarding once your able to start running real Scheme programs. Read R5RS for implementation details.and, or, cond, let, begin, etc. or you can just implement define-syntax and do the rest in Scheme. It all depends on whether you want a pure C implementation or just a tiny C core. Both have pros and cons (no pun, etc. etc.).
typedef struct obj
{
//manifest
struct {
unsigned int type : 5;
unsigned int gc : 1;
unsigned int vec : 1;
unsigned int pad : 9;
unsigned int size : 16;
};
union
{
struct obj *l;
signed int i;
float f;
char c;
} datum[0];
} obj;
datum[0]
union obj
{
struct {
unsigned int type : 5;
unsigned int gc : 1;
unsigned int vec : 1;
unsigned int pad : 9;
unsigned int size : 16;
} manifest;
union obj *l;
signed int i;
float f;
char c;
};
IDIV - Signed Integer Division
Usage: IDIV src
Modifies Flags: (AF,CF,OF,PF,SF,ZF undefined)