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 8:02

>>32-34
There is nothing "high fantasy novel" about writing self modifying programs.
... in Standard C. All of it is high fantasy. Because inline assembly and calling a function pointer that doesn't represent a function are C equivalents of deep magic and travelling through a wardrobe.

The first thing that comes to mind is that you would lose the ability to allocate data structure dynamically
Today I learned that I can't allocate data dynamically in Python, or that it has pointers. OK, let me rephrase, what do you lose if you turn C pointers into references, i.e. get rid of pointer arithmetic (while making array indexing a first class operation, obviously)?

Name: Anonymous 2013-12-30 19:13

>>40

Mainly to implement an "extension" language (i.e. plugins, user scripts etc) (or make it more efficient for the interpertation case). Almost all large systems come with an extension language, and even desktop productivity programs (e.g. CAD, CAS, EDA, image editing, document preparation, music composition etc. etc.).

Another use is emulation.

I suppose you could argue that it's just an optimization technique cause you could just write an interpreter for everything.

In software computer graphics JIT generation of efficient functions is an overt use of dynamic code generation for optimization.

idk there's lots of uses for it. Use your imagination.

Name: Anonymous 2013-12-30 19:31

>>41

There's no travelling through wardrobes involved. And you don't have to use assembly.

Also, you learned no such thing. However you're onto something; while it might sound stupid to you Python variables are, indeed, similar to pointers in C. For example pass a Python variable to a function and then mutate it's value in some way. Now do the same in C. Now look at the value of the variable in the caller after return. Now do the same but using a pointer in C.

Comparing "pointers" "names" "references" "variables" etc. across languages is not usually useful, because these words mean subtly different things in each language's community. Compare the real meaning of "variable" in Common Lisp (a language with first class symbols with a number of "namespaces" (again this means something very different to a C++ programmer or a Modula programmer)) to what it means in C or even Java or even Scheme. The C community makes a distinction between "lvalue" and "rvalue" which isn't that common outside the C community. etc. etc.

You just have to come to terms that the same words are used to mean completely different things when refering to different programming languages.

Name: Anonymous 2014-02-08 8:16

check 'em

Name: Anonymous 2014-02-08 12:33

>>1
What's the best way for a Schemer to learn Common Lisp?

Read Paul Graham's ANSI Common Lisp, that is mostly an extract from SICP, adapted to realities of CL. You won't learn much new, but will see how CL relates to Scheme.

Name: Anonymous 2014-02-08 12:34

>>45
Oh, I forgot, it is the OnLisp - another PG's book. ANSI Common Lisp book is useless.

Name: Anonymous 2014-02-09 5:42

>>39
#include <cling/Interpreter/Interpreter.h>
#include <cassert>
#include <iostream>

int main(int argc, char** argv) {
    cling::Interpreter interpreter(argc, argv);
    cling::StoredValueRef sillyFunc;
    int result = interpreter.evaluate("[](int i) { return i * i; }", sillyFunc);
    assert(result == cling::Interpreter::kSuccess);
    int (*silly)(int) = sillyFunc.get().getAs<int(*)(int)>();
    std::cout << silly(4) << std::endl;
    return 0;
}

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