D
Dave
Hello all,
I am creating a linked list implementation which will be used in a
number of contexts. As a result, I am defining its value node as type
(void *). I hope to pass something in to its "constructor" so that I
will be able to manipulate my list without the need for constant
casting; some sort of runtime type-safety mechanism.
For example, I want a linked lists of ints. I want to be able to say:
Newguy = ll_new(int); //so that in the future i can say:
Newguy.next.val++;
Or alternatively a list of bools:
Newerguy = ll_new([type]bool) //so that in the future i can say:
Newerguy.next.val = false;
Anyhow, I'm looking for ways to enforce runtime type-safety. Any
thoughts are appreciated, especially since I know for a fact this can
be done (and without unions...).
Dave
I am creating a linked list implementation which will be used in a
number of contexts. As a result, I am defining its value node as type
(void *). I hope to pass something in to its "constructor" so that I
will be able to manipulate my list without the need for constant
casting; some sort of runtime type-safety mechanism.
For example, I want a linked lists of ints. I want to be able to say:
Newguy = ll_new(int); //so that in the future i can say:
Newguy.next.val++;
Or alternatively a list of bools:
Newerguy = ll_new([type]bool) //so that in the future i can say:
Newerguy.next.val = false;
Anyhow, I'm looking for ways to enforce runtime type-safety. Any
thoughts are appreciated, especially since I know for a fact this can
be done (and without unions...).
Dave