Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ABCL 1.2.1 doesn't seem to work #4

Open
pnathan opened this issue Mar 31, 2014 · 5 comments · May be fixed by #10
Open

ABCL 1.2.1 doesn't seem to work #4

pnathan opened this issue Mar 31, 2014 · 5 comments · May be fixed by #10

Comments

@pnathan
Copy link

pnathan commented Mar 31, 2014

Using latest version in Quicklisp:

CL-USER> (paiprolog:<- (edge v1 v2))
EDGE
CL-USER> (paiprolog:<- (edge v0 v2))
EDGE
CL-USER> (paiprolog:<- (edge v0 v3))
EDGE
CL-USER> (paiprolog:?- (edge ?vertex1 ?vertex2))
No.
; No value
CL-USER> 

I've tested this on SBCL and it works there. Not sure if there is compiler-specific code in the codebase; if not, I'll go take it over to the ABCL mailing list.

@kg6y-ucd
Copy link
Contributor

kg6y-ucd commented Apr 1, 2016

I don't know why, but on ABCL bound-p returns T for unbound variable created by (?).
If you re-evaluate the definition of bound-p in REPL, this (bound-p's) problem disappears.

PAIPROLOG> (lisp-implementation-version)
"1.3.1"
"Java_HotSpot(TM)_Client_VM-Oracle_Corporation-1.8.0_20-b26"
"x86-Windows_XP-5.1"
PAIPROLOG> (<- (p 1))
P
PAIPROLOG> (?- (p ?x))
No.
; No value
PAIPROLOG> (bound-p (?))
T
PAIPROLOG> (defun bound-p (var) (not (eq (var-binding var) unbound))) ;; from prologc.lisp
STYLE-WARNING: redefining BOUND-P at top level
BOUND-P
PAIPROLOG> (bound-p (?))
NIL
PAIPROLOG> (?- (p ?x))
?X = 1;

No.
; No value
PAIPROLOG> 

@kg6y-ucd
Copy link
Contributor

kg6y-ucd commented Apr 1, 2016

When you embed debugging code in bound-p,
problem becomes apparent .

;;; prologcp.lisp
(defun bound-p (var)
  (print-unreadable-object ((var-binding var) t :identity t :type t))
  (terpri)
  (print-unreadable-object (unbound t :identity t :type t))
  (not (eq (var-binding var) unbound)))
PAIPROLOG> (bound-p (?))
#<(SIMPLE-BASE-STRING 7) {165B2C7}>
#<(SIMPLE-BASE-STRING 7) {184CA5F}>
T
PAIPROLOG> 

@kg6y-ucd
Copy link
Contributor

kg6y-ucd commented Apr 2, 2016

Changing (defconstant unbound ...) to (defvar unbound ...) in prologc.lisp might be a workaround for this problem.
This is a simplified test case to show this workaround.

;;; test-bound-p.lisp

#-ABCL
(defconstant unbound "Unbound")
#+ABCL
(defvar unbound "Unbound") ;; workaround for ABCL

(defstruct var 
  (binding unbound))

(defun bound-p (var)
  (print-unreadable-object ((var-binding var) t :identity t :type t))
  (terpri)
  (print-unreadable-object (unbound t :identity t :type t))
  (not (eq (var-binding var) unbound)))

(defun run ()
  (print (bound-p (make-var))))
CL-USER> (compile-file "./test-bound-p.lisp")
; Compiling C:/lispbox-0.7/quicklisp/local-projects/paiprolog/test-bound-p.lisp ...
; (DEFVAR UNBOUND ...)
; (DEFSTRUCT VAR ...)
; (DEFUN BOUND-P ...)
; (DEFUN RUN ...)
; Wrote c:/lispbox-0.7/quicklisp/local-projects/paiprolog/./test-bound-p.abcl (0.701 seconds)
#P"C:/lispbox-0.7/quicklisp/local-projects/paiprolog/test-bound-p.abcl"
NIL
NIL
CL-USER> (run)
; Evaluation aborted on #<UNDEFINED-FUNCTION {6BE0B7}>.
CL-USER> (load "./test-bound-p.abcl")
T
CL-USER> (run)
#<(SIMPLE-BASE-STRING 7) {1596BBE}>
#<(SIMPLE-BASE-STRING 7) {1596BBE}>
NIL 
NIL
CL-USER> (lisp-implementation-version)
"1.3.3"
"Java_HotSpot(TM)_Client_VM-Oracle_Corporation-1.8.0_20-b26"
"x86-Windows_XP-5.1"
CL-USER> 

quek added a commit that referenced this issue Apr 3, 2016
@quek quek linked a pull request Apr 3, 2016 that will close this issue
@quek
Copy link
Owner

quek commented Apr 3, 2016

#10
Dose this fix the problem?

@kg6y-ucd
Copy link
Contributor

kg6y-ucd commented Apr 3, 2016

No it doesn't. The patch below works for me.

uchita-akiko-no-macbook-2:paiprolog uchidamasako$ git diff
diff --git a/prologc.lisp b/prologc.lisp
index d44b203..2e667b3 100644
--- a/prologc.lisp
+++ b/prologc.lisp
@@ -7,11 +7,16 @@

 (in-package "PAIPROLOG")

-
+#-ABCL
 (defconstant unbound (if (boundp 'unbound)
                         (symbol-value 'unbound)
                         "Unbound"))

+#+ABCL
+(defvar unbound (if (boundp 'unbound)
+                    (symbol-value 'unbound)
+                    "Unbound"))
+
 (defvar *var-counter* 0)

 (defstruct (var (:constructor ? ())
uchita-akiko-no-macbook-2:paiprolog uchidamasako$ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants