wow, i can't believe this, i must be doing something wrong. first, here
is some code for discussion below:
> (eval-when (:compile-toplevel)
> (use-package :md))
>
> (in-package :cg-user)
>
> (defmodel dog ()
> ((mood :semaphor t :initarg :mood :initform nil :accessor mood)
> (action :semaphor t :initarg :action :initform nil :accessor action)))
>
ok. #'defmodel is a macro exported from the package :md (nickname for
:model).
the 'defmodel coded above defines macros for each slot, namely, #'^mood
and #'^action.
unfortunately, ^mood and ^action get defined in the :md package.
like i said, that seems wrong, as in "not what any one would ever want",
and Lisp generaly works the way I want, so...am I just wrong this time,
or am I doing something wrong?
kenny
It occurred to me to post the macro which defines the macros:
(defmacro defModel (class directSupers slotSpecs &rest options)
`(eval-when (:compile-toplevel :load-toplevel :execute)
,@(mapcar #'(lambda (slotSpec)
(destructuring-bind
(slotname &rest slotArgs &key semaphor accessor reader
&allow-other-keys)
slotSpec
(when semaphor
(let ((deriverFn (intern-user "^" (symbol-name (or
reader accessor slotname)))))
`(eval-when (:compile-toplevel :load-toplevel
:execute)
(defmacro ,deriverFn (&optional (model
'self) synFactory)
;; etc
)))))))))
more follows, but this is where the macros get defined.
kenny
Kenny Tilton wrote:
> wow, i can't believe this, i must be doing something wrong. first, here
> is some code for discussion below:
>
> > (eval-when (:compile-toplevel)
> > (use-package :md))
> >
> > (in-package :cg-user)
> >
> > (defmodel dog ()
> > ((mood :semaphor t :initarg :mood :initform nil :accessor mood)
> > (action :semaphor t :initarg :action :initform nil :accessor action)))
> >
>
> ok. #'defmodel is a macro exported from the package :md (nickname for
> :model).
>
> the 'defmodel coded above defines macros for each slot, namely, #'^mood
> and #'^action.
>
> unfortunately, ^mood and ^action get defined in the :md package.
>
> like i said, that seems wrong, as in "not what any one would ever want",
> and Lisp generaly works the way I want, so...am I just wrong this time,
> or am I doing something wrong?
>
> kenny
Kenny Tilton <·······@nyc.rr.com> writes:
> It occurred to me to post the macro which defines the macros:
>
> (defmacro defModel (class directSupers slotSpecs &rest options)
> `(eval-when (:compile-toplevel :load-toplevel :execute)
> ,@(mapcar #'(lambda (slotSpec)
> (destructuring-bind
> (slotname &rest slotArgs &key semaphor accessor reader
> &allow-other-keys)
> slotSpec
> (when semaphor
> (let ((deriverFn (intern-user "^" (symbol-name (or
> reader accessor slotname)))))
The interesting source would be the one to intern-user, which is
probably the cause for your troubles: To deliver on your
expectations, it should intern either in the current value of
*package* or less likely in the home packages of reader, accessor or
slotname. Instead it is probably interning in some fixed package,
like md.
> > > (eval-when (:compile-toplevel)
> > > (use-package :md))
> > >
> > > (in-package :cg-user)
> > >
> > > (defmodel dog ()
> > > ((mood :semaphor t :initarg :mood :initform nil :accessor mood)
> > > (action :semaphor t :initarg :action :initform nil :accessor action)))
Why do you have the use-package only evaluated at compile-time
(load-toplevel should be there, too), and why is it before the
in-package form? It's usually a bad idea to try to set up the package
structure in the same file that depends on it being in place, so I'd
rather have a package.cl file that set's up the package structure
before-hand, usually with defpackage...
Regs, Pierre.
--
Pierre R. Mai <····@acm.org> http://www.pmsf.de/pmai/
The most likely way for the world to be destroyed, most experts agree,
is by accident. That's where we come in; we're computer professionals.
We cause accidents. -- Nathaniel Borenstein
Thx, Pierre & Lieven, turns out during a global edit of my source I robotically
altered 'intern-user to intern in the :md package instead of :cg-user. duh....
But getting focused on that helped, I am going to remove the specification of any
package so that the 'defmodel macro always interns stuff in the current package.
thx again, kenny
"Pierre R. Mai" wrote:
> Kenny Tilton <·······@nyc.rr.com> writes:
>
> > It occurred to me to post the macro which defines the macros:
> >
> > (defmacro defModel (class directSupers slotSpecs &rest options)
> > `(eval-when (:compile-toplevel :load-toplevel :execute)
> > ,@(mapcar #'(lambda (slotSpec)
> > (destructuring-bind
> > (slotname &rest slotArgs &key semaphor accessor reader
> > &allow-other-keys)
> > slotSpec
> > (when semaphor
> > (let ((deriverFn (intern-user "^" (symbol-name (or
> > reader accessor slotname)))))
>
> The interesting source would be the one to intern-user, which is
> probably the cause for your troubles: To deliver on your
> expectations, it should intern either in the current value of
> *package* or less likely in the home packages of reader, accessor or
> slotname. Instead it is probably interning in some fixed package,
> like md.
>
> > > > (eval-when (:compile-toplevel)
> > > > (use-package :md))
> > > >
> > > > (in-package :cg-user)
> > > >
> > > > (defmodel dog ()
> > > > ((mood :semaphor t :initarg :mood :initform nil :accessor mood)
> > > > (action :semaphor t :initarg :action :initform nil :accessor action)))
>
> Why do you have the use-package only evaluated at compile-time
> (load-toplevel should be there, too), and why is it before the
> in-package form? It's usually a bad idea to try to set up the package
> structure in the same file that depends on it being in place, so I'd
> rather have a package.cl file that set's up the package structure
> before-hand, usually with defpackage...
>
> Regs, Pierre.
>
> --
> Pierre R. Mai <····@acm.org> http://www.pmsf.de/pmai/
> The most likely way for the world to be destroyed, most experts agree,
> is by accident. That's where we come in; we're computer professionals.
> We cause accidents. -- Nathaniel Borenstein
* Kenny Tilton wrote:
> It occurred to me to post the macro which defines the macros:
> (defmacro defModel (class directSupers slotSpecs &rest options)
> `(eval-when (:compile-toplevel :load-toplevel :execute)
> ,@(mapcar #'(lambda (slotSpec)
> (destructuring-bind
> (slotname &rest slotArgs &key semaphor accessor reader
> &allow-other-keys)
> slotSpec
> (when semaphor
> (let ((deriverFn (intern-user "^" (symbol-name (or
> reader accessor slotname)))))
> `(eval-when (:compile-toplevel :load-toplevel
> :execute)
> (defmacro ,deriverFn (&optional (model
> 'self) synFactory)
> ;; etc
> )))))))))
> more follows, but this is where the macros get defined.
You need to say what the INTERN-USER function does. Eventually you
want to be calling (INTERN <something> *PACKAGE*), or equivalently
(INTERN <something>), my guess it's calling (INTERN <something>
(FIND-PACKAGE :MD))
--tim
Kenny Tilton <·······@nyc.rr.com> writes:
> It occurred to me to post the macro which defines the macros:
>
How is #'INTERN-USER defined?
--
Lieven Marchand <···@bewoner.dma.be>
Lambda calculus - Call us a mad club