[ clisp-Bugs-2868151 ] (locally (declare (optimize...))) is ignored

View: New views
1 Messages — Rating Filter:   Alert me  

[ clisp-Bugs-2868151 ] (locally (declare (optimize...))) is ignored

by SourceForge.net :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bugs item #2868151, was opened at 2009-09-27 17:18
Message generated for change (Comment added) made by haible
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=101355&aid=2868151&group_id=1355

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: clisp
Group: lisp error
Status: Closed
Resolution: Invalid
Priority: 5
Private: No
Submitted By: Sam Steingold (sds)
Assigned to: Bruno Haible (haible)
Summary: (locally (declare (optimize...))) is ignored

Initial Comment:
(locally (declare (optimize ,,,))) has no effect on compile called inside locally - only the global optimize declarations are honored.


----------------------------------------------------------------------

>Comment By: Bruno Haible (haible)
Date: 2009-10-18 18:15

Message:
> it is not clear why declaim changes the result of compile while locally
does not.

DECLAIM is a macro wrapper around PROCLAIM. PROCLAIM establishes the
declarations in the global environment. So DECLAIM and PROCLAIM have an
effect with indefinite extent, not scoped. This is why (COMPILE 'F) may
actually see these changed declarations in the global environment.

Whether it actually does, depends on whether COMPILE takes the source code
of F and considers it in the current global environment (changed by
DECLAIM), or whether it takes a "frozen" form of the source code of F,
ignoring the current global environment. Both approaches are allowed, see
CLHS 3.2.2.3.

----------------------------------------------------------------------

Comment By: Sam Steingold (sds)
Date: 2009-10-18 15:53

Message:
it is not clear why declaim changes the result of compile while locally
does not.

----------------------------------------------------------------------

Comment By: Bruno Haible (haible)
Date: 2009-10-17 19:27

Message:
It is not a bug, but rather the expected behaviour.

Please remember to distinguish "scope" and "extent".
http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node43.html

The LOCALLY special form specifies declarations for code that is
lexically contained in this form. When you write (COMPILE NIL 'F)
the definition of F is not contained in the LOCALLY form;
therefore the declarations in effect at the COMPILE form are
irrelevant.

In other words, what matters is the declarations in effect at the
*definition* of F.

What you appear to want is some mechanism that establishes some
optimization settings for the code being compiled by the COMPILE
function, with dynamic extent. Such a mechanism cannot exist as an
override because, as mentioned above, what matters according to
CLHS 3.3 is the declarations in effect at the *definition* of F.
But what you can do is to change the defaults:
  (PROG2
    (DECLAIM (OPTIMIZE ...))
    (COMPILE NIL 'F)
    (DECLAIM (OPTIMIZE default-settings)))
Note that even this will not work across implementations, because
of the distinction between compile environment and execution
environment that some implementations make. See CLHS:DECLAIM
for details.


----------------------------------------------------------------------

Comment By: Sam Steingold (sds)
Date: 2009-10-15 19:51

Message:
this is NOT an ANSI compliance issue because the eval and compile
environments differ,
see http://clisp.podval.org/impnotes/compilation.html#semantic-constraints

----------------------------------------------------------------------

Comment By: Sam Steingold (sds)
Date: 2009-09-27 20:23

Message:
not quite.
(locally  (declare (optimize (safety X))) (disassemble (lambda (a) (aref a
0) 1)))
and
> (locally (declare (optimize (safety 3))) (funcall (compile nil
(lambda(a) (aref a 0) 1)) 3))
*** - AREF: argument 3 is not an array
> (locally (declare (optimize (safety 0))) (funcall (compile nil
(lambda(a) (aref a 0) 1)) 3))
1

works fine, but

(defparameter f (lambda (a) (aref a 0) 1))
(disassemble (locally (declare (optimize (safety X))) (compile nil f)))

prints the same regardless of X

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=101355&aid=2868151&group_id=1355

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
clisp-devel mailing list
clisp-devel@...
https://lists.sourceforge.net/lists/listinfo/clisp-devel