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

Common Lisp for Schemers

Name: fag 2013-12-29 0:49

What's the best way for a Schemer to learn Common Lisp? It seems like Scheme itself is a more beautiful language, but the efforts made by many implementations to make Scheme useful "in the real world" lead to a big ball of mud™. Does Common Lisp avoid this problem? Should I keep trying to learn different Scheme implementations instead until I find something I like?

Name: Anonymous 2013-12-30 0:52

>>31

Yes I am aware.

There is nothing "high fantasy novel" about writing self modifying programs.

First allocate some memory. Now get a pointer to that memory and write a program there. To "evaluate" that program either x86 JMP your way there (or equivalent inline assembler) or (, if your new program obeys the "host" (for lack of a better word) program's compiler's various conventions) cast the address to a function pointer. This is called run time (or dynamic) code generation. It's done all the time e.g. my Common Lisp implementation does it, as does the Hotspot JVM.

Now, If you want to change that program, then just write to that same memory. This is called "self modifying code".

If you want to specify the programs you write to that memory in some language, then you need to be able to compile that language. For example you may want to use libtcc if you wish to specify programs in C.

Now, because of "modern" operating systems you can't just allocate memory and have it be executable willy nilly; you have to ask first. If you are on Linux you want mman.h (specifically mprotect) and if you're on Windows you want Windows.h (specifically VirtualProtect). idk about other operating systems.

I should add in the case you want to modify the "host" program directly as it is in memory, you use function pointers or your compiler's equivalent of GCC's labels as values extension and then jump whatever hoops your operating system require you to.

Again, this is not esoteric, macho or arcane. It's just programming.

Name: Anonymous 2013-12-30 1:06

>>31

Now as for your question, "I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question"

Just kidding. Although it is an odd question.

The first thing that comes to mind is that you would lose the ability to allocate data structure dynamically, which is pretty important (if you need an example just think of a linked list or idk being able to read an unknown amount of images of unknown size from files at user request, I mean there's a million things you need dynamic memory for).

Name: Anonymous 2013-12-30 1:15

I should add that I interperted your question as "If you took pointers out of C what would you lose".

I don't know how to answer the question "If you took pointers out of any language what would you lose" because this depends on the language.

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