This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Redefining special operators

4 posts · 948 views

Is it possible, in sbcl, to redefine let (in another package which excludes cl:let)?

Re: Redefining special operators

Your question seems confused, so several points:

In general special operators are operators which require a special treatment by the compiler, and since the standard does not specify any details about operation of the compiler, you cannot define new special operators in a standard way. You can define non-special operators: functions and macros.

Redefining a meaning of a symbol in CL package has undefined consequences, since the standard specifies that the compiler is allowed to make the assumption that their meaning is constant, which means that redefining anything in CL, and especially any special operators will likely break the system.

Finally, operators are usually named by symbols. Symbols are first class entities, which almost always have a home package and a name. Symbols with just the same name are not related in any way, as long as they are not the same object. You can have as many symbols named "LET" as you want, associated with anything. If you want to have the reader resolve to such a symbol with the current package using the CL package, you can use the SHADOW function, or, better, the :SHADOW clause in DEFPACKAGE defining your package.

Do note that shadowing fundamental names such as LET will lead to confusion for anyone reading the code. It is recommended to use an alternative name for such cases, or at least consistently use a fully qualified form.

Re: Redefining special operators

I must have been in the cl package when i attempted to do this. It works now...

Re: Redefining special operators

sure you can, look here for example: http://github.com/ks/X.LET-STAR
this is how you make your defpackage:

(defpackage :your-lib
(:use :common-lisp :x.let-star ...)
(:shadowing-import-from x.let-star let*) ;; the important line
...)