3 ms·
I was gonna respond that you can't redefine the primitives because they're not functions or macros but special forms. And this seems true in Common Lisp. I can'
by mtlmtlmtlmtl 4y ago
I was gonna respond that you can't redefine the primitives because they're not functions or macros but special forms. And this seems true in Common Lisp. I can't define a function named SETQ(the primitive for assignment in CL, also called set! in other lisps) because it's a reserved name. But then I thought I'd try it in Guile and there I was allowed to (define define 5). Even though define is also a special form in Guile. Which made me unable to define further things, telling me 5 is not a valid argument to APPLY. And no I don't know how to fix it...
- deleted 4y ago[deleted]
- JadeNB 4y agoEvery language has the errors that it thinks you should not be allowed to make, and the errors that it trusts you to make on the assumption that you can determine whether you meant to make them better than the compiler. People complain on both sides of the permissiveness spectrum—they want a language that allows them to make exactly the errors that they want to make, but, of course, that set of errors differs from person to person!
- lispm 4y agoIn Common Lisp you can have namespaces, where you can have your own SETQ: CL-USER 53 > (defpackage mylisp (:use "COMMON-LISP") ; everything from Common Lisp (:shadow CL:SETQ)) ; but not SETQ #<The MYLISP package, 1/16 internal, 0/16 external> CL-USER 54 > (in-package "MYLISP") #<The MYLISP package, 1/16 internal, 0/16 external> MYLISP 55 > (defun setq (a b c) (print (list a b c))) SETQ MYLISP 56 > (setq (+ 1 2) 4 5) (3 4 5) (3 4 5) MYLISP 57 > (cl:setq a 12) 12 Most implementations also have a way to protect core symbols against redefinition and a way to do it anyway (possibly shooting yourself into the foot).
- mtlmtlmtlmtl 4y agoRight, I forgot about packages. Been far too long since I had an excuse to write Common Lisp :(