(n)sublis doesn't look inside backquoted expression

Bug #1659603 reported by ds26gte
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
SBCL
Invalid
Undecided
Unassigned

Bug Description

(sublis '((a . b) (c . d)) '`(,a ,b ,c ,d))

                   ;where the second arg is a backquoted list preceded by a regular quote

should produce (the equivalent of)

`(,B ,B ,D ,D)

Instead it produces

`(,A ,B ,C ,D)

Similar bug for nsublis. Reference correct implementations include: Clozure CL, ECL, MKCL, ECL, CLISP.

I'm using

ds26gte@longitude:~/tmp$ sbcl --version
SBCL 1.3.14.88-60d0ebeed
ds26gte@longitude:~/tmp$ uname -a
Linux longitude 4.8.0-34-generic #36-Ubuntu SMP Wed Dec 21 17:24:18 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

* *features*

(:QUICKLISP :SB-BSD-SOCKETS-ADDRINFO :ASDF-PACKAGE-SYSTEM :ASDF3.1 :ASDF3
 :ASDF2 :ASDF :OS-UNIX :NON-BASE-CHARS-EXIST-P :ASDF-UNICODE :64-BIT
 :64-BIT-REGISTERS :ALIEN-CALLBACKS :ANSI-CL :ASH-RIGHT-VOPS
 :C-STACK-IS-CONTROL-STACK :COMMON-LISP :COMPACT-INSTANCE-HEADER
 :COMPARE-AND-SWAP-VOPS :COMPLEX-FLOAT-VOPS :CYCLE-COUNTER :ELF :FLOAT-EQL-VOPS
 :FP-AND-PC-STANDARD-SAVE :GENCGC :IEEE-FLOATING-POINT :IMMOBILE-CODE
 :IMMOBILE-SPACE :INLINE-CONSTANTS :INTEGER-EQL-VOP :LARGEFILE :LINKAGE-TABLE
 :LINUX :LITTLE-ENDIAN :MEMORY-BARRIER-VOPS :MULTIPLY-HIGH-VOPS
 :OS-PROVIDES-BLKSIZE-T :OS-PROVIDES-DLADDR :OS-PROVIDES-DLOPEN
 :OS-PROVIDES-GETPROTOBY-R :OS-PROVIDES-POLL :OS-PROVIDES-PUTWC
 :OS-PROVIDES-SUSECONDS-T :PACKAGE-LOCAL-NICKNAMES :PRECISE-ARG-COUNT-ERROR
 :RAW-INSTANCE-INIT-VOPS :RAW-SIGNED-WORD :SB-DOC :SB-EVAL :SB-FUTEX :SB-LDB
 :SB-PACKAGE-LOCKS :SB-SIMD-PACK :SB-SOURCE-LOCATIONS :SB-TEST :SB-THREAD
 :SB-UNICODE :SBCL :STACK-ALLOCATABLE-CLOSURES :STACK-ALLOCATABLE-FIXED-OBJECTS
 :STACK-ALLOCATABLE-LISTS :STACK-ALLOCATABLE-VECTORS
 :STACK-GROWS-DOWNWARD-NOT-UPWARD :SYMBOL-INFO-VOPS :UNBIND-N-VOP :UNIX
 :UNWIND-TO-FRAME-AND-CALL-VOP :X86-64)

Thanks,

--d

Revision history for this message
Stas Boukarev (stassats) wrote :

Where does the standard state that this should happen?

Changed in sbcl:
status: New → Incomplete
Revision history for this message
Attila Lendvai (attila-lendvai) wrote :

isn't it undefined by the standard what the backquote reader reads into? you can only rely on its evaluation rules.

Revision history for this message
ds26gte (ds26gte) wrote :

While different Lisps do expand backquote in their own way, it remains that in all implementations the resulting expression is a tree, and in my example, the tree from the RHS does contain the symbols A, B, C, D as leaves.

The standard says: "sublis looks at all subtrees and leaves of _tree_; if a subtree or leaf appears as a key in _alist_ ... it is replaced ..."

Revision history for this message
Stas Boukarev (stassats) wrote :

SBCL doesn't use conses for representing ",", so, no trees for them.

Changed in sbcl:
status: Incomplete → Invalid
Revision history for this message
Brett van de Sande (bvds) wrote :

Warning, this behavior has changed in SBCL itself ...
In SBCL version 1.0.29:

* (sublis '((a . 1) (b . 2)) '(a `(,b 3)))

(1 `(,2 3))

In SBCL version 1.2.11:

* (sublis '((a . 1) (b . 2)) '(a `(,b 3)))

(1 `(,B 3))

I was unable to find any documentation associated with this change in behavior.
Quietly changing a behavior like this, with no warning messages, is not a good thing.

Revision history for this message
Brett van de Sande (bvds) wrote :
Revision history for this message
Attila Lendvai (attila-lendvai) wrote :

if you need to rely on the internal format of the quasi quote reader, then you can use this library instead of the implementation provided one:

http://quickdocs.org/fare-quasiquote/

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.