Boris Tschirschwitz wrote:
> 
> I'd like to see the foolowing three:
> 
> * Q: How come that if Lisp is so powerful, you can't overload functions?
> 
>    What about overloading operators like #'+?
>    Maybe also some reference to generic functions?

Personally, I'd use optional parameters for this. Here's a piece of
(probably awful) Lisp code to demonstrate:

(defun my+(num1 num2 &optional (num3 0))
        (+ num1 num2 num3))

(my+ 1 2) => 3
(my+ 1 2 3) => 6

For overloading by type, use typep to run different code for each type.
Like you, I got úsed to overloading in C++ but Lisp is actually more
flexible.

I actually prototype in Lisp and port the code to C++ for speed and
convenience, and C++ overloading actually helps cope with Lisp's wackier
concepts (like having a different remove_duplicates for each type to
compensate for C++'s lack of flexible data structures).

Jeremy.
-- 
| Jeremy Smith BSc (Hons)
| Chief Scientist, Decompiler Technologies
| <insert title here> at San Fran Systems
| Member, British Computer Society
| "And it's not just people you have to worry about. Programs write
programs too!" - Paul Graham, On Lisp
_______________________________________________
Gardeners mailing list
[email protected]
http://www.lispniks.com/mailman/listinfo/gardeners

Reply via email to