Hi you Lispniks out there!
While still being quite new to Lisp and CLOS I ran into the following
error:
(using ACL Trial 6.2 on Debian Linux)
Error: :CREATOR :NAME are invalid initargs to make-instance of class
#<STANDARD-CLASS FRGO:ROOT-INSTANTIABLE-OBJECT>. The valid
initargs are FRGO::NAME FRGO::CREATOR.
[condition type: PROGRAM-ERROR]
I created the following code:
----
(cl:in-package :cl-user) ; Just to be sure...
(defpackage :frgo (:use #:cl))
(in-package #:frgo)
(eval-when (:compile-toplevel :load-toplevel :execute)
(export '( version-info
baseline
root-instantiable-object
make-object )))
;;; -------------------------------------------------------------------------
;;; CLASSES
;;; -------------------------------------------------------------------------
(defclass version-info ()
(( current-sequence-nr :accessor current-sequence-nr :initform 0 )
( version-index :accessor version-index :initform nil )
( revision-index :accessor revision-index :initform nil )))
(defclass versionable-object ()
(( version-info :accessor version-info :initform nil )
( data :accessor data :initform nil )
( modification-info :accessor modification-info :initform nil )))
(defclass root-instantiable-object ( versionable-object )
(( name :accessor name :initarg name )
( id :accessor id :initform nil )
( creator :accessor creator :initarg creator )
( owner :accessor owner :initform nil )))
(defun make-object (name creator)
(make-instance 'root-instantiable-object
:name name
:creator creator))
;;; -------------------------------------------------------------------------
;;; METHODS
;;; -------------------------------------------------------------------------
(defmethod initialize-instance :after ((object versionable-object) &key)
(setf (version-info object) (make-instance 'version-info)))
(defmethod initialize-instance :after ((object root-instantiable-object) &key)
(incf (current-sequence-nr object)))
;;; -------------------------------------------------------------------------
;;; END OF SOURCE TEXT
;;; -------------------------------------------------------------------------
(cl:in-package :cl-user)
----
Hm. Why this? I am in that package so the symbols should be visible...
Or what?
Plz help me "getting it".
Thx.
Regards,
Frank
From: Barry Margolin
Subject: Re: Error: :CREATOR :NAME are invalid initargs !? Plz help!
Date:
Message-ID: <iRgmb.231$lK3.169@news.level3.com>
In article <··············@stargate.de.goenninger.com>,
Frank Goenninger DG1SBG <······@darc.de> wrote:
>
>Hi you Lispniks out there!
>
>While still being quite new to Lisp and CLOS I ran into the following
>error:
>
>(using ACL Trial 6.2 on Debian Linux)
>
>Error: :CREATOR :NAME are invalid initargs to make-instance of class
> #<STANDARD-CLASS FRGO:ROOT-INSTANTIABLE-OBJECT>. The valid
> initargs are FRGO::NAME FRGO::CREATOR.
> [condition type: PROGRAM-ERROR]
...
>(defclass root-instantiable-object ( versionable-object )
> (( name :accessor name :initarg name )
> ( id :accessor id :initform nil )
> ( creator :accessor creator :initarg creator )
> ( owner :accessor owner :initform nil )))
>
>(defun make-object (name creator)
> (make-instance 'root-instantiable-object
> :name name
> :creator creator))
Your class definition says that the initargs are CREATOR and NAME, not
:CREATOR and :NAME. Initargs are *not* automatically put in the keyword
package; if you want to use keywords, write
:initarg :name
:initarg :creator
--
Barry Margolin, ··············@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Better put the package definition in one file and the rest of the code in
another.
e.g
------beginning of file1
(in-package :cl-user)
(defpackage :frgo (:use :cl))
(eval-when (:compile-toplevel :load-toplevel :execute)
(export '( version-info
baseline
root-instantiable-object
make-object )))
-------end of file 1
and
------- beginning of file2
;;; ------------------------------------------------------------------------
-
;;; CLASSES
;;; ------------------------------------------------------------------------
-
(defclass version-info ()
(( current-sequence-nr :accessor current-sequence-nr :initform 0 )
( version-index :accessor version-index :initform nil )
( revision-index :accessor revision-index :initform nil )))
(defclass versionable-object (version-info)
(( version-info :accessor version-info :initform nil )
( data :accessor data :initform nil )
( modification-info :accessor modification-info :initform nil )))
(defclass root-instantiable-object ( versionable-object )
(( name :accessor name :initarg name )
( id :accessor id :initform nil )
( creator :accessor creator :initarg creator )
( owner :accessor owner :initform nil )))
(defun make-object (name creator)
(make-instance 'root-instantiable-object
:name name
:creator creator))
;;; ------------------------------------------------------------------------
-
;;; METHODS
;;; ------------------------------------------------------------------------
-
(defmethod initialize-instance :after ((object versionable-object) &key)
(setf (version-info object) (make-instance 'version-info)))
(defmethod initialize-instance :after ((object root-instantiable-object)
&key)
(incf (current-sequence-nr object)))
------- end of file2
I think you also want versionable-object to inherit from version-info,
otherwise the initialize-after will fail or
probably better specialise on version-info instead of
root-instantiable-object. (not really a root, no?)
saludos
Karsten
"Frank Goenninger DG1SBG" <······@darc.de> wrote in message
···················@stargate.de.goenninger.com...
>
> Hi you Lispniks out there!
>
> While still being quite new to Lisp and CLOS I ran into the following
> error:
>
> (using ACL Trial 6.2 on Debian Linux)
>
> Error: :CREATOR :NAME are invalid initargs to make-instance of class
> #<STANDARD-CLASS FRGO:ROOT-INSTANTIABLE-OBJECT>. The valid
> initargs are FRGO::NAME FRGO::CREATOR.
> [condition type: PROGRAM-ERROR]
>
"Karsten Poeck" <······@terra.es> writes:
Hallo Karsten (your name sounds German, but your email suggests Spain...) !
> Better put the package definition in one file and the rest of the code in
> another.
>
> e.g
> ------beginning of file1
>
> (in-package :cl-user)
>
> (defpackage :frgo (:use :cl))
>
> (eval-when (:compile-toplevel :load-toplevel :execute)
> (export '( version-info
> baseline
> root-instantiable-object
> make-object )))
> -------end of file 1
> and
> ------- beginning of file2
> ;;; ------------------------------------------------------------------------
> -
> ;;; CLASSES
> ;;; ------------------------------------------------------------------------
> -
Yes, OK, sure, of course. I will, I promise. Well, thanks for pointing out.
[snipped away some code]
>
> ;;; ------------------------------------------------------------------------
> -
> ;;; METHODS
> ;;; ------------------------------------------------------------------------
> -
>
> (defmethod initialize-instance :after ((object versionable-object) &key)
> (setf (version-info object) (make-instance 'version-info)))
>
> (defmethod initialize-instance :after ((object root-instantiable-object)
> &key)
> (incf (current-sequence-nr object)))
> ------- end of file2
>
>
> I think you also want versionable-object to inherit from version-info,
> otherwise the initialize-after will fail or
> probably better specialise on version-info instead of
> root-instantiable-object. (not really a root, no?)
Thx again. I already noticed I should specialize on version-info.
For "root" - well, it should be the root class of all other classes
that a potential user/sw developer should inherit from for application
classes.
Why do you ask?
>
> saludos
>
> Karsten
>
Gr��le, (Swabish for "Regards")
Frank
From: Marco Antoniotti
Subject: Re: Error: :CREATOR :NAME are invalid initargs !? Plz help!
Date:
Message-ID: <gtanb.77$KR3.39674@typhoon.nyu.edu>
Karsten Poeck wrote:
> Better put the package definition in one file and the rest of the code in
> another.
>
Ahem. :) Pardon the bluntness, but it is better to put the
"stylistically and programmer friendly" package definition in one package
> e.g
> ------beginning of file1
>
> (in-package :cl-user)
>
> (defpackage :frgo (:use :cl))
>
> (eval-when (:compile-toplevel :load-toplevel :execute)
> (export '( version-info
> baseline
> root-instantiable-object
> make-object )))
> -------end of file 1
======= file foo-package.lisp =========
;;; -*- Mode: Lisp -*-
(defpackage "FRGO" (:use "COMMON-LISP")
(:export "VERSION-INFO"
"BASELINE"
"ROOT-INSTANTIABLE-OBJECT"
"MAKE-OBJECT"))
======= end of file ====================
Cheers
--
Marco