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

Lisp challenge

Name: Anonymous 2014-09-13 7:11

Lisp macros can do anything, they say. But can they do typeclasses?
For the purpose of feasibility study, I'll simplify the challenge, of course. It will go like this:

Implement the form mappend such that

(mappend 2 3)

expands to

(+ 2 3)

and

(mappend "arst" "neio")

expands to

(concatenate 'string "arst" "neio")

(the above code is in Common Lisp, but you're free to use any Lisp and substitute the corresponding forms from that Lisp).

The expansion must happen no later than compile-time, with no runtime overhead.

Feel free to use Typed Racket, Shen, Arc, Clojure or any other Lisp.

Name: Anonymous 2014-09-13 10:32

>>1
How are you meant to do it with no runtime overhead when it's a dynamically typed language? That makes no sense. I mean, sure, in dialects like Clojure you can use type hints which (I'm assuming) would cause it to be expanded at compile time, but that's dependent on the context in which the macro is being used.

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