From: Peter S. <pe...@pj...> - 2015-05-21 03:29:59
|
By picking an exact symbol to use for the placeholder (instead of any-symbol-with-name), the standard lets code that processes array type declarations (mostly the compiler, but code-walkers and macros get involved here too) use EQ (fast) instead of some-test-ultimately-involving-STRING= (slow). This comes at the minor cost that people doing strange things (shadowing CL:* hint, hint) will be inconvenienced (but not inhibited, since you can access the correct symbol using the package syntax). I don't think there is anywhere in the standard that requires the use of a symbol-of-a-particular-name without also specifying a package (generally the package CL) For some problems like this you could do the equivalent of shadowing DECLARE with your own TEST-DECLARE2:DECLARE which would do the appropriate mapping so you didn't have to worry about using the package prefix for *, but (again for efficiency reasons) you are explicitly denied writing macros that expand into (pure) DECLARE forms. On 21/05/15 01:42, Harvey Stein wrote: > I'm surprised by the behavior of declare when * is shadowed. In > particular, the following works fine: > > (defpackage :test-declare1 > (:use :common-lisp) > (:shadow "*")) > > (in-package :test-declare1) > > (defun fcn (x) > (declare (type (simple-array double-float (cl:*)) x)) > (cl:* (aref x 1) 2d0)) > > > but, the following signals an error: > > (in-package :common-lisp) > > (defpackage :test-declare2 > (:use :common-lisp) > (:shadow "*")) > > (in-package :test-declare2) > > (defun fcn (x) > (declare (type (simple-array double-float (*)) x)) > (cl:* (aref x 1) 2d0)) > > > ; file: /home/hjstein/lisp/cls/packtest2.lisp > ; in: DEFUN FCN > ; (TYPE (SIMPLE-ARRAY DOUBLE-FLOAT (TEST-DECLARE2::*)) > TEST-DECLARE2::X) > ; > ; caught ERROR: > ; bad dimension in array type: * > ; > ; compilation unit finished > ; caught 1 ERROR condition > > I was surprised because semantically, the "*" in the (declare ...) > form is just a place holder for the dimension. Why does it have to be > the actual cl:* symbol and not just any symbol with name "*"? > > Thanks, > Harvey > > -- > Harvey J. Stein > hj...@gm... <mailto:hj...@gm...> > http://www.linkedin.com/in/harveyjstein > Selected papers and presentations available at: > http://ssrn.com/author=732372 > > > ------------------------------------------------------------------------------ > One dashboard for servers and applications across Physical-Virtual-Cloud > Widest out-of-the-box monitoring support with 50+ applications > Performance metrics, stats and reports that give you Actionable Insights > Deep dive visibility with transaction tracing using APM Insight. > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y > > > _______________________________________________ > Sbcl-devel mailing list > Sbc...@li... > https://lists.sourceforge.net/lists/listinfo/sbcl-devel |