J
Jean-Guillaume Pyraksos
I want to work with "generalized lists" as in Lisp, say :
((23 () . 2) () ((10))) ; only pointers and integers
So the basic element is a node, a struct with two fields car and cdr.
Each of these fields can contain either a pointer (NULL or a pointer to
another node), or an int.
I want to define the functions cons, car and cdr of Lisp.
I tried this but gcc rejects it :
#include <stdio.h>
#include <stdlib.h>
typedef struct {
object car;
object cdr;
} node;
typedef struct {
int tag; // 0==int, 1==node*
union {
int value;
node *ptr;
} val;
} object;
node* cons(object a, object b) { ...}
Can you help ? Thanks...
JG
((23 () . 2) () ((10))) ; only pointers and integers
So the basic element is a node, a struct with two fields car and cdr.
Each of these fields can contain either a pointer (NULL or a pointer to
another node), or an int.
I want to define the functions cons, car and cdr of Lisp.
I tried this but gcc rejects it :
#include <stdio.h>
#include <stdlib.h>
typedef struct {
object car;
object cdr;
} node;
typedef struct {
int tag; // 0==int, 1==node*
union {
int value;
node *ptr;
} val;
} object;
node* cons(object a, object b) { ...}
Can you help ? Thanks...
JG