Changes between Initial Version and Version 1 of Ticket #867


Ignore:
Timestamp:
06/12/11 22:17:15 (4 years ago)
Author:
gb
Comment:

In Common Lisp, "variables" can be "constant variables" (defined with DEFCONSTANT), "special variables" (variables for which a SPECIAL declaration applies, often established with DEFVAR or DEFPARAMETER), or "lexical variables" (variables bound by LET/LAMBDA in the surrounding context for which no SPECIAL declaration is in effect.

SYM2 in your code above fits into none of these categories. In CCL, it'll sort of be treated as a SPECIAL variable for the purposes of reference and assignment, but bindings of the variable will be (new) lexical bindings. Other implementations behave at least slightly differently, and most compilers will warn when such variables are encountered. (In CCL, the compiler refers to such variables as "Undeclared free varables": they're not lexically bound and not declared to be SPECIAL or CONSTANT variables.)

Most interpreters don't warn about use of these variables, and people are often casual about introducing such (formally undefined but practically harmless, usually) variables in forms that they type into the REPL; some books and tutorials are equally casual about this.

In CCL, some forms typed into the REPL are evaluated by a very simple interpreter; other forms are evaluated by compiling them and calling the resulting anonymous function. The simple interpreter doesn't warn about the use of SYM2 in

? (setf sym2 'sym1)

though the use of SYM2 there isn't (strictly speaking) well-defined. The compiler does warn about the use of SYM2 in the DO form, and the text of that warning precedes the other output.

There's no other difference in behavior between the two cases (besides the fact that the code in the second DO generated a compiler warning.) I can't quite understand your diagnosis of what you see, but I'm as confident as I can be in saying that you haven't discovered a bug in DO.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #867

    • Property Status changed from new to closed
    • Property Resolution changed from to invalid
  • Ticket #867 – Description

    initial v1  
    66Line breaks added for readability: 
    77 
     8{{{ 
    89? (setf (get 'sym1 'prop) '(this that theother)) 
    9  
    1010(THIS THAT THEOTHER) 
    11  
    1211? (setf sym2 'sym1) 
    13  
    1412SYM1 
    15  
    16 ? (do ((lst (symbol-plist 'sym1) (cdr lst))) ((null lst) t) (princ (car lst))) 
    17  
     13? (do ((lst (symbol-plist 'sym1) (cdr lst)))  
     14      ((null lst) t)  
     15   (princ (car lst))) 
    1816PROP(THIS THAT THEOTHER) 
    19  
    2017T 
    21  
    22 ? (do ((lst (symbol-plist sym2) (cdr lst))) ((null lst) t) (princ (car lst))) 
    23  
     18? (do ((lst (symbol-plist sym2) (cdr lst)))  
     19      ((null lst) t)  
     20    (princ (car lst))) 
    2421;Compiler warnings : 
    25  
    2622;   In an anonymous lambda form at position 24: Undeclared free variable SYM2PROP(THIS THAT THEOTHER) 
    27  
    2823T 
    29  
    3024?  
     25}}} 
    3126 
    3227Thank you for ccl, btw.  It seems incredibly fast, which matters for my application.