Re: compatibility package for ANSI CL?
Kent M Pitman <[email protected]> Fri, 5 Apr 2002 16:37:32 -0500
| Newsgroups | gmane.lisp.org.slug |
|---|---|
| Message-ID | <[email protected]> |
Date: Fri, 05 Apr 2002 13:23:40 -0500 From: Clinton Hyde <[email protected]> ... > 2) when my defpackage was :use'ing FUTURE-COMMON-LISP, > #'(lambda ...) expanded as (cl:function (future-common-lisp:lambda ...)) > which didn't work. Using Syntax: Common-Lisp and package Common-Lisp > instead of Syntax: ANSI-Common-Lisp and Common-Lisp or Future-Common-Lisp > solved the problem. I hate all these screwy package use, import and ordering problems... Do you like being able to use multiple dialects in the same image? CLTL and ANSI CL are incompatible. The few little setups you have to do to say whose semantics you want is a small price to pay. For best results, use package names that are appropriate to the syntax. The syntax named "Common-Lisp" is the CLTL syntax. We did not change its meaning when ANSI CL came around because huge quantities of code would be broken. CLTL calls its user package USER. Start from that package to get a foothold as in: ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: USER; -*- and build your other CLTL-based packages here. You won't have any problems. *** OR *** work in the ANSI-Common-Lisp universe. In that case, do: ;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Package: CL-USER -*- and build your ANSI CL packages here. But if :use FUTURE-COMMON-LISP , you are almost surely going to confuse yourself. We kept that old package name for compatibility with old code, which probably continues to work fine. But it's MUCH better to use call that package CL and to call FUTURE-COMMON-LISP-USER just CL-USER from within the ANSI-Common-Lisp syntax. They only have the long names if you use them outside of that syntax. I'm not at my LispM, so I don't remember the precise command, but Zmacs and the listener have different names. Use the command Set Lisp Context in one of them and Set Lisp Syntax in the other in order to assure you are in the ANSI-Common-Lisp syntax. As long as you work consistently inside these, you will be fine. It's when you try to use Common-Lisp syntax but FUTURE-COMMON-LISP operators, or ANSI Common Lisp syntax but the old Common Lisp package that you'll have trouble. Don't blame all of this on "having to do syntax". Syntax is your friend. The alternative to small syntax details like this would have been "massive incompatible change" and "loss of ability to cross-call old and new programs". That's a pretty steep price to pay. > 3) Using Common-Lisp, just defmacro'ing declaim to future-common-lisp:declaim > did the trick. the "Right Thing" here is more probably (setf (function 'declaim) (function 'fcl:declaim)) I'd prefer the syntax ANSI-CL:::CL:DECLAIM. It's less likely to go away. Not that many things are likely to change, but... The triple-colon designates a syntax. e.g., ZL:::USER:X means the same as ZL-USER:X. and CL:::USER::X means the same as CL-USER::X. *** BUT ordinarily you should not need to do this because you should work in the right syntax. If you are writing new code, just _always_ use Syntax: ANSI-Common-Lisp; and you'll be able to use package names "CL" and "CL-USER" and you'll not have to talk about "FCL" or "FCL-USER" at all. or (defpackage YOUR-PKG (:import (fcl:declaim)) ...) Much better to just do the defpackage in the right syntax and the package will inherit from the ANSI CL package to begin with. When importing from other packages in ANSI CL, though, you should prefer (:import-from "PACKAGENAME" "SYM1" "SYM2" ...) instead of (:import PACKAGENAME:SYM1 PACKAGENAME:SYM2 ...). Diclaimers: I'm no longer a Symbolics employee. I no longer speak with any formal authority, if I ever did. When I say "we", I mean the "we" of long ago. I did implement a lot of the the syntax substrate, btw.