Hacker News new | ask | show | jobs
by ctdonath 5271 days ago
"Lisp programmers should stop reading right now because they'll likely suffer severe injury of the jaw muscles as they laugh themselves silly at how hard it is to do some things in C."

Naive question: in Lisp, how would you set the byte at address 0xDEADBEEF to 0x42?

3 comments

There are some who would suggest that allowing you to commit segment violations is not generally a desirable language feature.
Except when 0xDEADBEEF happens to be the memory address overlaying the custom hardware registers, and setting it to 0x42 turns the blinky light on. There are some cases where manipulating static memory locations is not only a good thing, but the only way to do something (at least for embedded programming). Not saying that your point is invalid, btw.
wild guess:

  (overlay 'light #on)
overlay being a macro to access a predefined ffi setup.

</dream>

The ability to commit segment violations is a consequence of the broader abilities you get with pointers as a language feature. In many cases, neither of those things are desirable, but there are cases (e.g., systems programming) where they are very desirable.
Sure, but LISP was never intended as a systems or embedded programming language. Criticizing LISP for not being good at doing low-level tasks is akin to criticizing Harley-Davidson's motorcycles because they don't float.
Or akin to criticizing C for not being an expressive, high-level language.

Also, in response to your first point: http://en.wikipedia.org/wiki/Lisp_machine

If C would have lisp syntax it could do the alot of the same abstractions.
A low-level imperative language with s-expression syntax would be one heck of an esoteric language.
It's very simple:

(setf (cffi:mem-ref (cffi:make-pointer #xDEADBEEF) :int) #x42)

Define a C type and use FFI to set the value in memory.

Quite easy.