[Nickle] Funny situation
Bart Massey
bart at cs.pdx.edu
Sat Jun 28 01:55:52 PDT 2003
What am I doing wrong here? Or is this a Nickle bug?
Consider this little class:
namespace List {
public typedef list;
typedef union {
struct {
poly first;
list rest;
} cell;
void nil;
} elem;
public typedef &elem list;
public list cons(poly v, list l) {
elem n = { cell = { first = v, rest = &l } };
return &n;
}
public poly car(list l) {
return l.cell.first;
}
public list cdr(list l) {
return &l.cell.rest;
}
public bool null(list l) {
union switch(l) {
case cell c:
return false;
case nil:
return true;
}
}
elem nilcell = { nil = <> };
public list empty = &nilcell;
}
Now if I try
list l = empty;
I get an error: also for any variant I can think of.
Of course
list l;
&l = ∅
works, but uggh. Comments?
Bart
More information about the Nickle
mailing list