Hi, I'm trying out the PAIP examples located at
http://www.norvig.com/paip/README.html . While I thought Corman and
Allegro seemed very good and helpful for small programs, Corman
doesn't load the first two steps:
(load "d:\\paip\\auxfns.lisp")
(requires "examples")
properly, whereas Allegro does but gives many warnings about
redefining TRUE and PRODUCT, until it literally quits itself (!)
executing a later chapter after printing out:
"Error: Attempt to make a TYPE definition for the name PATH as a
DEFSTRUCT. This name is in the COMMON-GRAPHICS package and defining
it is a violation for portable programs. The package COMMON-GRAPHICS
has PACKAGE-DEFINITION-LOCK set, which causes the system to signal
this violation.
[condition type: PACKAGE-LOCKED-ERROR]"
I'm used to Java, and I'd like some advice on how to think of this.
Is it one of the following:
- PAIP known to use nonstandard CL
- Corman and Allegro diverge from the standards
- Windows XP is the wrong CL platform
- The CL standard gives lots of leeway to conforming implementations
- CL community has grown some conventions beyond the standard
- Something is buggy
I've just pointed out loading problems to the Corman list. Thanks for
any guidance.
-- Red
I had no trouble with the following in Lispworks for Windows
Professional Edition. Their Personal Edition is available for free
download and I know people who do a lot of work with the Personal Edition.
CL-USER 1 > (change-directory "c:/lisp/projects/paip/paip")
#P"c:/lisp/projects/paip/paip/"
CL-USER 2 > (load "auxfns")
; Loading text file c:\lisp\projects\paip\paip\auxfns.lisp
#P"c:/lisp/projects/paip/paip/auxfns.lisp"
CL-USER 3 > (requires "examples")
; Loading text file c:\lisp\projects\paip\paip\examples.lisp
; Loading text file c:\lisp\projects\paip\paip\tutor.lisp
; Loading text file c:\lisp\projects\paip\paip\auxfns.lisp
("examples")
CL-USER 4 >
Note that change-directory is in Lispwork's HCL package (Harlequin
Common Lisp). Change-directory does not appear in the Common Lisp
Hyperspec, which is standard.
Perhaps others can help with the other Lisp implementations.
R. Walters wrote:
> Hi, I'm trying out the PAIP examples located at
> http://www.norvig.com/paip/README.html . While I thought Corman and
> Allegro seemed very good and helpful for small programs, Corman
> doesn't load the first two steps:
> (load "d:\\paip\\auxfns.lisp")
> (requires "examples")
> properly, whereas Allegro does but gives many warnings about
> redefining TRUE and PRODUCT, until it literally quits itself (!)
> executing a later chapter after printing out:
>
> "Error: Attempt to make a TYPE definition for the name PATH as a
> DEFSTRUCT. This name is in the COMMON-GRAPHICS package and defining
> it is a violation for portable programs. The package COMMON-GRAPHICS
> has PACKAGE-DEFINITION-LOCK set, which causes the system to signal
> this violation.
> [condition type: PACKAGE-LOCKED-ERROR]"
>
> I'm used to Java, and I'd like some advice on how to think of this.
> Is it one of the following:
> - PAIP known to use nonstandard CL
> - Corman and Allegro diverge from the standards
> - Windows XP is the wrong CL platform
> - The CL standard gives lots of leeway to conforming implementations
> - CL community has grown some conventions beyond the standard
> - Something is buggy
>
> I've just pointed out loading problems to the Corman list. Thanks for
> any guidance.
> -- Red
··········@yahoo.com (R. Walters) writes:
> Hi, I'm trying out the PAIP examples located at
> http://www.norvig.com/paip/README.html . While I thought Corman and
> Allegro seemed very good and helpful for small programs, Corman
> doesn't load the first two steps:
> (load "d:\\paip\\auxfns.lisp")
> (requires "examples")
> properly, whereas Allegro does but gives many warnings about
> redefining TRUE and PRODUCT, until it literally quits itself (!)
> executing a later chapter after printing out:
>
> "Error: Attempt to make a TYPE definition for the name PATH as a
> DEFSTRUCT. This name is in the COMMON-GRAPHICS package and defining
> it is a violation for portable programs. The package COMMON-GRAPHICS
> has PACKAGE-DEFINITION-LOCK set, which causes the system to signal
> this violation.
> [condition type: PACKAGE-LOCKED-ERROR]"
COMMON-GRAPHICS is not a standard package (only COMMON-LISP
is). Having it impored in COMMON-LISP-USER may be the problem if it
has symbols in common with PAIP. Then you may want to define and work
in your own package:
(DEFPACKAGE "PAIP-USER"
(:USE "COMMON-LISP"))
(IN-PACKAGE "PAIP-USER")
;; AND THE (SETF (LOGICAL-PATHNAME-TRANSLATIONS "NORVIG") ...)
;; AND (LOAD...) BELOW.
> I'm used to Java, and I'd like some advice on how to think of this.
> Is it one of the following:
> - PAIP known to use nonstandard CL
> - Corman and Allegro diverge from the standards
> - Windows XP is the wrong CL platform
> - The CL standard gives lots of leeway to conforming implementations
> - CL community has grown some conventions beyond the standard
> - Something is buggy
>
> I've just pointed out loading problems to the Corman list. Thanks for
> any guidance.
> -- Red
Here is the file I load to load PAIP examples. It works in clisp and
sbcl. I would not say that the first two steps are only:
(load "d:\\paip\\auxfns.lisp")
(requires "examples")
You need to define a logical host translation before loading my loader:
(SETF (LOGICAL-PATHNAME-TRANSLATIONS "NORVIG")
(LIST
(LIST "**;*" "D:\\PAIP\\**\*"))
(LIST "**;*.*" "D:\\PAIP\\**\*.*"))
(LIST "**;*.*.*" "D:\\PAIP\\**\*.*.*"))
))
(LOAD "norvig.lisp")
-----------------------------(norvig.lisp)------------------------------
;;****************************************************************************
;;FILE: norvig.lisp
;;LANGUAGE: Common-Lisp
;;SYSTEM: -
;;USER-INTERFACE: -
;;DESCRIPTION
;;
;; Loader for Norvig's code
;;
;;AUTHORS
;; <PJB> Pascal Bourguignon
;;MODIFICATIONS
;; 2003-05-14 <PJB> Created.
;;BUGS
;;LEGAL
;; GPL
;;
;; Copyright Pascal Bourguignon 2003 - 2003
;; ··········@informatimago.com
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version
;; 2 of the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be
;; useful, but WITHOUT ANY WARRANTY; without even the implied
;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;; PURPOSE. See the GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public
;; License along with this program; if not, write to the Free
;; Software Foundation, Inc., 59 Temple Place, Suite 330,
;; Boston, MA 02111-1307 USA
;;****************************************************************************
(DEFPARAMETER CONFIGURATION
'(GPS-SEARCH ELISA-PM PROLOG-CP KREP SYNTAX-3 SCHEME-3 SCHEME-C3))
(DEFMACRO EXCLUSIVE (&REST E-B)
(LET ((ETIQUETTES (MAPCAR (FUNCTION CAR) E-B))
(REP (GENSYM "REP")))
`(LET ((,REP (INTERSECTION CONFIGURATION ',ETIQUETTES)))
(IF (= 1 (LENGTH ,REP))
(PROGN
(SETQ ,REP (CAR ,REP))
(FORMAT T "~&CONFIGURED: ~A~%" ,REP))
(SETQ ,REP
(DO ((,REP NIL))
(,REP ,REP)
(FORMAT *QUERY-IO* "~&Please choose what to load from ~S: "
',ETIQUETTES)
(SETQ ,REP (READ *QUERY-IO*))
(UNLESS (MEMBER ,REP ',ETIQUETTES) (SETQ ,REP NIL)))))
(CASE ,REP
,@E-B))))
(DEFVAR *PAIP-SOURCE-FILES*
(TRANSLATE-LOGICAL-PATHNAME (MAKE-PATHNAME
:HOST "NORVIG"
:DIRECTORY '(:ABSOLUTE)
:NAME NIL
:TYPE "LISP"))
"The location of the source files for this book.
CHANGE IT TO REFLECT THE LOCATION OF THE FILES ON YOUR COMPUTER.")
(LOAD "norvig:intro.lisp") ;; A few simple definitions
(LOAD "norvig:simple.lisp") ;; Random sentence generator (two versions)
(LOAD "norvig:overview.lisp") ;; 14 versions of LENGTH and other examples
(LOAD "norvig:auxmacs.lisp") ;; A few macros; load this first.
(UNLESS (FBOUNDP 'COMMON-LISP:LOOP)
(LOAD "norvig:loop.lisp")) ;; Load if your Lisp doesn't support ANSI LOOP
(LOAD "norvig:auxfns.lisp") ;; Commonly used auxiliary functions.
(LOAD "norvig:search.lisp") ;; Search Utility
;; "norvig:search.dat" ;; Test data (examples) for above
(EXCLUSIVE
(GPS-SIMPLE
(LOAD "norvig:gps1.lisp") ;; Simple version of General Problem Solver
;; "norvig:gps1.dat" ;; Test data (examples) for above
)
(GPS
(LOAD "norvig:gps1.lisp") ;; Simple version of General Problem Solver
(LOAD "norvig:gps.lisp") ;; Final version of General Problem Solver
;; "norvig:gps.dat" ;; Test data (examples) for above
)
(GPS-SEARCH
(LOAD "norvig:gps1.lisp") ;; Simple version of General Problem Solver
(LOAD "norvig:gps.lisp") ;; Final version of General Problem Solver
(LOAD "norvig:gps-srch.lisp") ;; Version of GPS using the search utility
;; "norvig:gps-srch.dat" ;; Test data (examples) for above
))
(LOAD "norvig:patmatch.lisp") ;; Pattern Matching Utility
;; "norvig:patmatch.dat" ;; Test data (examples) for above
(EXCLUSIVE
(ELISA-BASIC
(LOAD "norvig:eliza1.lisp") ;; Basic version of Eliza program
)
(ELISA
(LOAD "norvig:eliza.lisp") ;; Eliza with more rules; different reader
)
(ELISA-PM
(LOAD "norvig:eliza-pm.lisp") ;; Version of Eliza using utilities
(LOAD "norvig:cmacsyma.lisp") ;; Efficient Macsyma with canonical form
;; "norvig:cmacsyma.dat" ;; Test data (examples) for above
))
(LOAD "norvig:student.lisp") ;; The Student Program
;; "norvig:student.dat" ;; Test data (examples) for above
(LOAD "norvig:macsyma.lisp") ;; The Macsyma Program
(LOAD "norvig:macsymar.lisp") ;; Simplification & integration rules for Macsyma
;; "norvig:macsyma.dat" ;; Test data (examples) for above
(LOAD "norvig:unify.lisp") ;; Unification functions
(EXCLUSIVE
(PROLOG1
(LOAD "norvig:prolog1.lisp") ;; First version of Prolog interpreter
;; "norvig:prolog1.dat" ;; Test data (examples) for above
)
(PROLOG
(LOAD "norvig:prolog.lisp") ;; Final version of Prolog interpreter
;; "norvig:prolog.dat" ;; Test data (examples) for above
)
(PROLOG-C1
(LOAD "norvig:prologc1.lisp") ;; First version of Prolog compiler
;; "norvig:prologc1.dat" ;; Test data (examples) for above
)
(PROLOG-C2
(LOAD "norvig:prologc2.lisp") ;; Second version of Prolog compiler
;; "norvig:prologc2.dat" ;; Test data (examples) for above
)
(PROLOG-C
(LOAD "norvig:prologc.lisp") ;; Final version of Prolog compiler
;; "norvig:prologc.dat" ;; Test data (examples) for above
)
(PROLOG-CP
;;(LOAD "norvig:prologcp.lisp") ;; Primitives for Prolog compiler
;;(LOAD "norvig:unifgram.lisp") ;; Unification Parser
;; "norvig:unifgram.dat" ;; Test data (examples) for above
;;(LOAD "norvig:lexicon.lisp") ;; Sample Lexicon of English
;; "norvig:grammar.dat" ;; Test data (examples) for above
(LOAD "norvig:grammar.lisp") ;; Comprehensive grammar of English
))
(LOAD "norvig:clos.lisp") ;; Some object-oriented and CLOS code
;; "norvig:clos.dat" ;; Test data (examples) for above
(EXCLUSIVE
(KREP-1
(LOAD "norvig:krep1.lisp") ;; Knowledge Representation code: first version
;; "norvig:krep1.dat" ;; Test data (examples) for above
)
(KREP-2
(LOAD "norvig:krep2.lisp") ;; Knowledge Representation code w/ conjunctions
)
(KREP
(LOAD "norvig:krep.lisp") ;; Final KR code: worlds and attached functions
))
(LOAD "norvig:mycin.lisp") ;; The Emycin expert system shell
(LOAD "norvig:mycin-r.lisp") ;; Some rules for a medical application of emycin
;; "norvig:mycin.dat" ;; Test data (examples) for above
(LOAD "norvig:waltz.lisp") ;; A Line-Labeling program using Waltz algorithm
;; "norvig:waltz.dat" ;; Test data (examples) for above
;; (LOAD "norvig:othello.lisp") ;; The Othello playing program & strategies
;; "norvig:othello.dat" ;; Test data (examples) for above
(LOAD "norvig:othello2.lisp") ;; Additional strategies for Othello
(LOAD "norvig:edge-tab.lisp") ;; Edge table for Iago strategy
(EXCLUSIVE
(SYNTAX-1
(LOAD "norvig:syntax1.lisp") ;; Syntactic Parser
;; "norvig:syntax1.dat" ;; Test data (examples) for above
)
(SYNTAX-2
(LOAD "norvig:syntax2.lisp") ;; Syntactic Parser with semantics
;; "norvig:syntax2.dat" ;; Test data (examples) for above
)
(SYNTAX-3
(LOAD "norvig:syntax3.lisp") ;; Syntactic Parser with semantics and pref.
;; "norvig:syntax3.dat" ;; Test data (examples) for above
))
(EXCLUSIVE
(SCHEME-1
(LOAD "norvig:interp1.lisp") ;; Scheme interpreter, incl. version with macros
;; "norvig:interp1.dat" ;; Test data (examples) for above
)
(SCHEME-2
(LOAD "norvig:interp1.lisp") ;; Scheme interpreter, incl. version with macros
(LOAD "norvig:interp2.lisp") ;; A tail recurive Scheme interpreter
)
(SCHEME-3
(LOAD "norvig:interp1.lisp") ;; Scheme interpreter, incl. version with macros
(LOAD "norvig:interp3.lisp") ;; A Scheme interpreter that handles call/cc
;; "norvig:interp3.dat" ;; Test data (examples) for above
))
(EXCLUSIVE
(SCHEME-C1
(LOAD "norvig:compile1.lisp") ;; Simple Scheme compiler
)
(SCHEME-C2
(LOAD "norvig:compile2.lisp") ;; Compiler with tail recursion and primitives
)
(SCHEME-C3
(LOAD "norvig:compile3.lisp") ;; Compiler with peephole optimizer
(LOAD "norvig:compopt.lisp") ;; Peephole optimizers for compile3.lisp
;; "norvig:compile.dat" ;; Test data (examples) for all 3 versions above
))
;;;; norvig.lisp -- 2003-05-16 07:54:59 -- pascal ;;;;
------------------------------------------------------------------------
--
__Pascal_Bourguignon__ http://www.informatimago.com/
----------------------------------------------------------------------
Do not adjust your mind, there is a fault in reality.
··········@yahoo.com (R. Walters) writes:
> I'm used to Java, and I'd like some advice on how to think of this.
> Is it one of the following:
> - PAIP known to use nonstandard CL
IRC, at the time the book was written ansi cl hadn't yet converged, so
there are indeed some superficial incompatibilies. I obscurely
remember having read so in the preface or somewhere else in the book
(don't have it handy here).
Regards,
Mario.