Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

godfuckingdamnit!/prog/

Name: Anonymous 2010-02-06 15:49

hey /prog/

im writing a lisp interpreter from scratch in C (or rather trying to) and i dont know how to represent a general lisp object . i also dont know how to implement ˝lambda˝ and ˝apply˝ , or rather a function which generates a function and returns its address.

any ideas /prog/ ?
is it even possible to write a function that generates a function in C ?
and how the fuck does one make a struct member with undefined lenght/variable ?

Name: Anonymous 2010-02-06 16:39

>>7
So C is only for producing program which has a clear logic without being able to change the program itself ? i assume this has to be because of the format of most executable formats , they cant modify themselfs can they and even if you could one would have to make hacks in the paged memmory , right ?
ANSI C is one thing. The implementation and platform are other things. You can do whatever you want in practice, as long as you can deal with the consequences. Yes, programs can be self-modifying. Assembly code can be self-modifying on some architectures, including x86. Lisp code can be self-modifying to a certain extent (recompiling and replacing functions and data at runtime). C code can be self modifying using platform specific ways (not directly ANSI C). Let's not try to confuse the platform with the language.

i also try to understand what lisp really is and how it works .
You don't really need to write your own Lisp in C, but you're free too. Metacircular implementations or some simple compilers would make it more clear, if you already know Lisp. Doing it in C just means you'll just define the base data types from scratch, this isn't really anything that complex, just read some implementation source code to see how it works. There's also a good book about implementing Scheme interpreters and compilers that might be of interest to you: Lisp in Small Pieces.

>>11
i was hopeing to avoid pointers
Why? Even my most trivial C programs make use of pointers if I want to be able to support non-constrained external data. Lisp objects are so dynamic, that I'd be very surprised if you managed to avoid using pointers. I can only imagine the kind of abuse you'd have to do to avoid pointers. I think it's really not worth going to such lengths to avoid them.
my idea was to make a struct containing a internal identifier number of specific type for the data and right after it the data itself without it being seperated across the mem .
You would still need pointers to operate on that data, even if you avoid using pointers in the actual structure representation.
in SICP it is calling either a primitive procedure or evaling a all the elements in the function , again i wanted to avoid this and generate a function just like the primitive ones using lambda but this seems very difficult .
You want to break a vicious metacircular cicle? Sure, just implement the special operators directly. I'm not so sure I understand the remaining part of your statement.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List