Creating CONS cells in more primative languages.
Posted: Mon Feb 10, 2014 7:14 pm
I've been toying with the idea of trying to make a mini lisp in C++.
We don't need another Lisp, I'm just trying to make something real time that can be parsed and fed back into C++ primitives at runtime.
What's in a CONS cell?
I mean we know there are two pointers, one to point to the next CONS or the value NULL.
Another to point to a value.
Are there implied parts of a CONS cell that are often abstracted away?
Should a CONS cell keep references to it's parents? (I suppose it could keep a count and every time a parent dies it could decrement the child's ref counter by 1 until it hits 0 and destroys the child CONS)
Perhaps the biggest problem is that CONS cells can keep any type of data inside.
One moment the cons can store an INT the next it's storing a string and the next, an entire list.
Should a CONS cell be immutable?
Should it be simply replaced when the value is changed?
It is one thing to just USE a Lisp varient.
It is quite another to implement one in languages that are not garbage collected and very type safe.
Any ideas here?
I'm sure at least one person has implemented a mini Lisp for amusement.
I know there are probably articles and code snippets all over but I'm curious to hear about people here.
We don't need another Lisp, I'm just trying to make something real time that can be parsed and fed back into C++ primitives at runtime.
What's in a CONS cell?
I mean we know there are two pointers, one to point to the next CONS or the value NULL.
Another to point to a value.
Are there implied parts of a CONS cell that are often abstracted away?
Should a CONS cell keep references to it's parents? (I suppose it could keep a count and every time a parent dies it could decrement the child's ref counter by 1 until it hits 0 and destroys the child CONS)
Perhaps the biggest problem is that CONS cells can keep any type of data inside.
One moment the cons can store an INT the next it's storing a string and the next, an entire list.
Should a CONS cell be immutable?
Should it be simply replaced when the value is changed?
It is one thing to just USE a Lisp varient.
It is quite another to implement one in languages that are not garbage collected and very type safe.
Any ideas here?
I'm sure at least one person has implemented a mini Lisp for amusement.
I know there are probably articles and code snippets all over but I'm curious to hear about people here.