From: Frederic Warin
Subject: Common Lisp problem
Date: 
Message-ID: <539@muller.loria.fr>
I've already posted a problem for a friend but the answers I received
do not solve it. Here is a more complete description of what happens.

I have a big problem in Lucid Common Lisp (running on Sun Sparc Slc,
openwindow, SunOS 4.1.1). This is Sun Common Lisp 4.0.2.

Some people have already answered to me, and I thank them very much, but
their solutions do not solve my problem.

It will be great if someone could help me.

The aim is :  generate lisp code for saving the value of variables.
As these variables are complex, I wanted to use the propertie offered by
setting the *print-structure* and *print-array* to the t value.
When one is printing the value of the structure, it will be done in detail
rather than an adress only.

The problem is : when the structure is a recursive one, some objects are not
referenced. They are just described as a #:g1234 (for example) object.
That means the package of the object is unknown. And that is not true.

Here are the descriptions of my "defstructs" :

(in-package :kheops :use '(lisp))

(deftype domaine () '(integer 0 *))
(defstruct attribut
  (sexp nil :type (or symbol list))
  (type t :type (member bool symb int real t))
  (arite 0 :type (integer 0 *))
  (champs nil :type list)
  (tests nil :type list)
  (indice -1 :type integer)
  entree?
  sortie?
  (indice-sortie -1 :type integer))
(defstruct attribut-special attribut valeur-precedente)
(defstruct (entree-speciale (:include attribut-special)))
(defstruct (sortie-speciale (:include attribut-special)))
(defstruct objet-lpe attribut domaine)
(defstruct appartient
  (value nil :type list))
(defstruct entre binf bsup)
(deftype logique () '(member vrai faux ?))
(defstruct condition
  (valeur-logique '? :type logique)
  pere)
(defstruct (et-ou (:include condition))
  (compteur2 0 :type (integer 0 *))
  conditions)
(defstruct (et (:include et-ou)))
(defstruct (ou (:include et-ou)))
(defstruct (non (:include condition))
  (condition nil :type (or null condition)))
(defstruct (test (:include condition))
  (objet-lpe nil :type (or null objet-lpe))
  (corps nil :type (or null appartient entre)))
(defstruct (test-negatif (:include test)))
(defstruct (test-connu (:include condition)) attribut)
(defstruct (reduction (:include objet-lpe))
  (corps nil :type (or null appartient entre)))
(defstruct (reduction-negative (:include reduction)))
(defstruct appel-externe sexp chaine-C indice)
(defstruct connu sexp attributs)
(defstruct regle
  nom
  (antecedent nil :type (or null test test-connu et ou non))
  consequent
  indice)
(defstruct (dependance (:include regle)))
(defstruct (sinon (:include regle)))
(defstruct interface attribut value)
(defstruct noeud actions numero pere regles)
(defstruct (noeud-interne (:include noeud)) fils)
(defstruct (noeud-ou (:include noeud-interne)) attribut)
(defstruct (noeud-et (:include noeud-interne)))
(defstruct (noeud-terminal (:include noeud)) type)
(defstruct declaration sexp)
(defstruct (declaration-C (:include declaration)))
(defstruct (declaration-simple-C (:include declaration)) type)
(defstruct (definition-structure-C (:include declaration-C)))
(defstruct (creation-structure-C (:include declaration-C)))
(defstruct (creation-tableau-C (:include declaration-C)))
(defstruct (autre-declaration-C (:include declaration-C))
  chaine-C-corps chaine-C-entete)
(defstruct (declaration-lisp (:include declaration)))
(defstruct declarations
  declarations-simples-C
  definitions-structures-C
  creations-structures-C
  creations-tableaux-C
  autres-declarations-C
  declarations-lisp)
(defstruct compte-rendu
  nb-noeud-ou nb-noeud-et nb-feuille nb-inconsistance
  nb-incompletude-partielle nb-incompletude-totale nb-elagage
  nb-noeud-developpe nb-rgp-loc nb-rgp-glob profondeur-max temps
  regles-non-activees regles-inutiles)
(defstruct kheops
  (nom "")
  dictionnaire
  entrees
  entrees-utilisateur
  sorties
  entrees-speciales
  sorties-speciales
  regles
  dependances
  sinons
  appels-externes
  noeuds
  arbre
  (boot (make-attribut :sexp '*boot* :type t :arite 1))
  (declarations (make-declarations))
  initialisations
  compte-rendu
  external-declarations
  (time-unit :cycle)
  hashed-dictionary
  (tmp-dictionary (make-hash-table :size 10 :test #'equal)))

Here is the lisp file containing the object I want to save :

(in-package (quote user))
(setq *k* 
      (quote
       #S(kheops::kheops 
	  nom "cpm" 
	  dictionnaire #(#1=#S(kheops::attribut 
			       sexp v 
			       type symb 
			       arite 2 
			       champs (b) 
			       tests nil 
			       indice 0 
			       entree? nil
			       sortie? t
			       indice-sortie 0) 
			    #2=#S(kheops::attribut 
				  sexp x 
				  type symb 
				  arite 2 
				  champs (a)
				  tests (#3=#S(kheops::test 
					       valeur-logique kheops::?
					       pere #4=#S(kheops::regle 
							  nom r1 
							  antecedent #3# 
							  consequent 
							  (#S(kheops::reduction 
							      attribut #1# 
							      domaine 1 
							      corps 
							      #S(kheops::appartient value (b))))
							  indice 0) 
					       objet-lpe #S(kheops::objet-lpe 
							    attribut #2# 
							    domaine 1) 
					       corps #S(kheops::appartient value (a))))

				  indice 1 
				  entree? t 
				  sortie? nil
				  indice-sortie -1))
	  entrees #() 
	  entrees-utilisateur #() 
	  sorties #() 
	  entrees-speciales #()
	  sorties-speciales #() 
	  regles #()
	  dependances #() 
	  sinons #() 
	  appels-externes #() 
	  noeuds #()
	  arbre () 
	  boot () 
	  declarations ()
	  initialisations #() 
	  compte-rendu ()
	  external-declarations nil 
	  time-unit :cycle 
	  hashed-dictionary nil 
	  tmp-dictionary nil)))
 
Here is my lisp session :

;;; Dribble file "session" started
t
> (setq *print-structure* t)
t
> (setq *print-array* t)
t
> (setq *print-case* :downcase)
:downcase
> (load "struct")
;;; Loading source file "struct.lisp"
#P"/tmp_mnt/home/balzac/struct.lisp"
> (load "cpm")
;;; Loading source file "cpm.lisp"
#P"/tmp_mnt/home/balzac/cpm.lisp"
> *k*
#S(kheops::kheops nom "cpm" dictionnaire #(#S(kheops::attribut sexp v type symb arite 2 champs (b) tests nil indice 0 entree? nil sortie? t indice-sortie 0) #S(kheops::attribut sexp x type symb arite 2 champs (a) tests (#S(kheops::test valeur-logique kheops::? pere #S(kheops::regle nom r1 antecedent #:g1682 consequent (#S(kheops::reduction attribut #S(kheops::attribut sexp v type symb arite 2 champs (b) tests nil indice 0 entree? nil sortie? t indice-sortie 0) domaine 1 corps #S(kheops::appartient value (b



)))) indice 0) objet-lpe #S(kheops::objet-lpe attribut #:g1681 domaine 1) corps #S(kheops::appartient value (a)))) indice 1 entree? t sortie? nil indice-sortie -1)) entrees #() entrees-utilisateur #() sorties #() entrees-speciales #() sorties-speciales #() regles #() dependances #() sinons #() appels-externes #() noeuds #() arbre nil boot nil declarations nil initialisations #() compte-rendu nil external-declarations nil time-unit :cycle hashed-dictionary nil tmp-dictionary nil)
> (dribble)
;;; Dribble file "session" finished


You can see that some references have been replaced by #:gxxx.

Thank you very much for your suggestions.



Please, answer to ·····@loria.fr


-- 

·····@loria.fr
Frederic Warin		Crin/Inria Lorraine	France