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-15 4:46

>>8

evaluating the arguments during compile-time defeats the intended purpose of makeshift type classes.

In practice you'll have to explicitly supply type signature. I.e. invoke (mappend a b) as (mappend (the string a) (the string b))

That is why statically typed languages are always harder to learn and more involved than dynamically typed ones. Otherwise Java wouldn't have lost to JavaScript.

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