The structure-ext Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The structure-ext Reference Manual

This is the structure-ext Reference Manual, version 0.0.3, generated automatically by Declt version 4.0 beta 2 "William Riker" on Tue Nov 15 07:17:30 2022 GMT+0.

Table of Contents


1 Introduction

Tested.


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 structure-ext

Tiny structure extensions

Author

Shinichi Sato

License

MIT

Version

0.0.3

Dependencies
Source

structure-ext.asd.

Child Component

package.lisp (file).


2.2 structure-ext.left-arrow-accessors

Slot accessor alias maker.

Author

Shinichi Sato

License

MIT

Long Description

# STRUCTURE-EXT.LEFT-ARROW-ACCESSORS 0.0.6

## introduction
Any language has direction.
In this context, "direction" means order of explain.
For example, English has "from center to around" direction, and Japanese has "from around to center" direction.

E.g. person name.
In English notation, my name is written as ’Shinichi Sato’.
Shinichi is first name (of course center), and Sato is family name (of course around).
But in Japanese notation, my name is written as "佐藤 真一".
"佐藤" equals "Sato", and "真一" equals "Shinichi".

Also day unit.
In English notation, its written "Day Month Year".
It aims from small unit to bigger unit.
But in Japanese notation, its written "年月日".
"年" equals "year", "月" equals "month", and "日" equals "Day".
It aims from big unit to smaller unit.

Also address notations.
In English notation, its written from small place like town to huge place like prefecture, state, etc...
But in Japanese notation, its written from huge place like prefecture to small place like town, street etc...

Of course each language has inversion though.

Also programming language is one kind of language.
In such context, we can refer center as "return value", and around as "algorithm".
Roughly, we can say imperative language has Japanese style "from around to center" direction, and functional language has English style "from center to around" direction.

## Current lisp world
In lisp comunity, functional programming style is recommended.
Language is carefully designed to be able to write functional style easily.
For example, LET’s binding is designed "from center to around"(var is center(It is what we want.), and init form is around.), METHOD’s specializer is designed so too, WITH-SLOTS’s alias is same, etc...

## Issues
But there is few "from around to center" rule in CL.
It is slot accessor or slot accessor style function name like CHAR-CODE.

## Proposal
Using left arrow instead of hyphen is proposed.
Do you think which code is easy to understand?

“‘lisp
(code-char n)
(char<=code n)
“‘
I bet it is almost same.
There is just small differences only.
But in many cases, we don’t write such low level code as toplevel.
Usually we nests it.
So how below?

“‘lisp
(defun example1 (symbol)
(let ((name (package-name (symbol-pakcage symbol))))
...))
(defun example2 (symbol)
(let ((name (name<=package (package<=symbol symbol))))
...))
“‘
In former case, relational part appears alternately.
While reading code from left to right, the stack in your brain acting violently like seesaw but later case.

There is no probrem with class, because we can specify arbitraly name as readers/writers/accessors, but structure.

## Usage

“‘lisp
(defstruct foo bar)
(DEFINE-LEFT-ARROW-ACCESSORS foo bar)
(bar<=foo (make-foo :bar 0))
=> 0
“‘

## From developer

* Product’s goal - already?
* License - MIT
### Tested
* SBCL/2.0.2
* CCL/1.12
* CLISP/2.49
* ECL/20.4.24

Version

0.0.7

Source

structure-ext.left-arrow-accessors.asd.

Child Component

left-arrow-accessors.lisp (file).


2.3 structure-ext.make-instance

Method make-instance for construct structure.

Author

Shinichi Sato

License

MIT

Version

0.1.1

Dependency

closer-mop (system).

Source

structure-ext.make-instance.asd.

Child Component

make-instance.lisp (file).


2.4 structure-ext.as-class

Defstruct as defclass

Author

Shinichi Sato

License

MIT

Long Description

# STRUCTURE-EXT.AS-CLASS 0.0.6

## Current lisp world
Common Lisp has strong structure and class.

## Issues
In Common Lisp comunity, subject ’structure vs class’ is issued sometimes.

Only structure can do is nothing.
Only class can do is Multiple inheritance.

NOTE - Here, we ignores the thing which can not do but there is a way.
E.g. class is unreadable, but we can write reader macro.
E.g. structure does not have shared slot, but we can emulate it with symbol-plist.

So roughly, we can say ’if you need multiple inheritance, use class. otherwise structure. Because structure is fast.’

“‘Lisp
(defstruct foo slot)
(defclass bar () ((slot :initarg :slot :accessor bar-slot)))

;; constructor
(time (dotimes (x 1000) (make-foo :slot 0)))
=> 299,098 processor cycles
16,376 bytes consed
(time (dotimes (x 1000) (make-instance ’bar :slot 0)))
=> 19,777,048 processor cycles
187,400 bytes consed
;; 66 times faster, 11.5 times less consed.

;; accessor
(let ((s (make-foo :slot 0)))
(time (dotimes (x 1000) (foo-slot s))))
=> 26,771 processor cycles
(let ((c (make-instance ’bar :slot 0)))
(time (dotimes (x 1000) (bar-slot c))))
=> 143,488 processor cycles
;; 5.3 times faster.
“‘

## Proposal
DEFSTRUCT\* is almost same syntax with CL:DEFSTRUCT, but expanded into DEFCLASS and DEFMETHOD forms.
At first, start to write your application with CL:DEFSTRUCT.
If you need multiple inheritance, change CL:DEFSTRUCT to DEFSTRUCT\*, and add super class as :include option. DEFSTRUCT\* can accept multiple :include options.

## Constraints
### Invalid options
Option :type, :named, and :initial-offset are invalid in DEFSTRUCT\*

### Uncompleteness of copier
The copy function which is made by DEFSTRUCT\* has some constraints.

* Any slots has CL:ERROR initform.
* All slots are not specified :READ-ONLY T.

Because, copier evaluates ‘CL:MAKE-INSTANCE‘ without any initargs,
then ‘CL:SETF‘ each slots.

## Usage

## From developer

* Product’s goal - already?
* License - MIT
### Tested
* SBCL/2.0.2
* CCL/1.12
* CLISP/2.49
* ECL/20.4.24

Version

0.0.8

Dependencies
  • lambda-fiddle (system).
  • closer-mop (system).
  • uiop (system).
Source

structure-ext.as-class.asd.

Child Component

as-class.lisp (file).


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


3.1.1 structure-ext/structure-ext.asd

Source

structure-ext.asd.

Parent Component

structure-ext (system).

ASDF Systems

structure-ext.


3.1.2 structure-ext.left-arrow-accessors/structure-ext.left-arrow-accessors.asd

Source

structure-ext.left-arrow-accessors.asd.

Parent Component

structure-ext.left-arrow-accessors (system).

ASDF Systems

structure-ext.left-arrow-accessors.


3.1.3 structure-ext.make-instance/structure-ext.make-instance.asd

Source

structure-ext.make-instance.asd.

Parent Component

structure-ext.make-instance (system).

ASDF Systems

structure-ext.make-instance.


3.1.4 structure-ext.as-class/structure-ext.as-class.asd

Source

structure-ext.as-class.asd.

Parent Component

structure-ext.as-class (system).

ASDF Systems

structure-ext.as-class.


3.1.5 structure-ext/package.lisp

Source

structure-ext.asd.

Parent Component

structure-ext (system).

Packages

structure-ext.


3.1.6 structure-ext.left-arrow-accessors/left-arrow-accessors.lisp

Source

structure-ext.left-arrow-accessors.asd.

Parent Component

structure-ext.left-arrow-accessors (system).

Packages

structure-ext.left-arrow-accessors.

Public Interface
Internals

3.1.7 structure-ext.make-instance/make-instance.lisp

Source

structure-ext.make-instance.asd.

Parent Component

structure-ext.make-instance (system).

Packages

structure-ext.make-instance.


3.1.8 structure-ext.as-class/as-class.lisp

Source

structure-ext.as-class.asd.

Parent Component

structure-ext.as-class (system).

Packages

structure-ext.as-class.

Public Interface

defstruct* (macro).

Internals

4 Packages

Packages are listed by definition order.


4.1 structure-ext.as-class

Source

as-class.lisp.

Nickname

as-class

Use List

common-lisp.

Used By List

structure-ext.

Public Interface

defstruct* (macro).

Internals

4.2 structure-ext.make-instance

Source

make-instance.lisp.

Nickname

makins

Use List

common-lisp.


Previous: , Up: Packages   [Contents][Index]

4.4 structure-ext.left-arrow-accessors

Source

left-arrow-accessors.lisp.

Nickname

larac

Use List

common-lisp.

Used By List

structure-ext.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Macros

Macro: define-left-arrow-accessors (type &rest slot*)

# DEFINE-LEFT-ARROW-ACCESSORS

## Description:
Define accessor aliases.

“‘lisp
#?(defstruct foo bar bazz)
=> FOO
, :lazy
“‘

“‘lisp
#?(define-left-arrow-accessors foo bar)
=> (BAR<=FOO)
, :test
“‘

“‘lisp
#?(bar<=foo (make-foo :bar 0))
=> 0
, :around
“‘

“‘lisp
#?(bazz<=foo (make-foo :bazz 0))
:signals (or undefined-function
warning ; for ccl
)
“‘

### syntax
(DEFINE-LEFT-ARROW-ACCESSORS type &rest slot\*)
=> result

## Arguments and Values:
type := symbol which is structure name, otherwise error.

“‘lisp
#?(define-left-arrow-accessors "FOO" bazz)
:signals error
“‘

“‘lisp
#?(define-left-arrow-accessors bar bazz)
:signals error
“‘
slot* := symbol which is slot-name, otherwise error.

“‘lisp
#?(define-left-arrow-accessors foo "BAR")
:signals error
“‘

“‘lisp
#?(define-left-arrow-accessors foo hoge)
:signals error
“‘
result := list which includes defined accessor names.

## Affected By:
lisp image status.

## Side-Effects:
define new functions in current package.

## Notes:

## Exceptional-Situations:

Package

structure-ext.left-arrow-accessors.

Source

left-arrow-accessors.lisp.

Macro: defstruct* (&body body)

# DEFSTRUCT\*

## Description:
Define class by defstruct syntax.

### syntax
(DEFSTRUCT\* &body body)
=> result

“‘lisp
#?(defstruct* foo bar)
=> FOO
, :lazy
“‘

“‘lisp
#?(make-foo)
:be-the foo
“‘

“‘lisp
#?(foo-bar (make-foo :bar 0))
=> 0
“‘

“‘lisp
#?(foo-p (make-foo))
:satisfies identity
“‘

“‘lisp
#?(let* ((foo (make-foo :bar 0))
(copied (copy-foo foo)))
(values (eq foo copied)
(foo-bar copied)))
:multiple-value-satisfies (lambda ($samep $copied-bar-value)
(& (null $samep)
(= 0 $copied-bar-value)))
“‘

## Arguments and Values:
see CL:DEFSTRUCT.

## Affected By:
none

## Side-Effects:
none

## Notes:

## Exceptional-Situations:
:initial-offset, :type and :named option is invalid.

“‘lisp
#?(defstruct* (bar (:type list))
hoge fuga)
:signals error
“‘

“‘lisp
#?(defstruct* (bar (:initial-offset 4))
hoge fuga)
:signals error
“‘
specify both :print-function and :print-object is invalid.

“‘lisp
#?(defstruct* (bar (:print-function bar-printer)
(:print-object (lambda (&rest args) (print args))))
hoge fuga)
:signals error
“‘

## Examples
simplest form

“‘lisp
#?(defstruct* hoge bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
with initform.

“‘lisp
#?(defstruct* hoge
(bar 0))
; <— specified.
:expanded-to
“‘
Specify type.

“‘lisp
#?(defstruct* hoge
(bar 0 :type integer))
; <— specified.
:expanded-to
“‘
Specify read-only T.

“‘lisp
#?(defstruct* hoge
(bar 0 :read-only T))
; <— specified.
:expanded-to
“‘
Conc-name option example.
Specify no prefix.

“‘lisp
#?(defstruct* (hoge (:conc-name nil)) ; <— Specify.
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor bar))) ; <— This! (defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
Same above.

“‘lisp
#?(defstruct* (hoge (:conc-name)) bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor bar))) ; <— This! (defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
Specify alternative.

“‘lisp
#?(defstruct* (hoge (:conc-name hoge-)) ; <— Specify
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar))) ; <— This! (defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
Can use string-designator.

“‘lisp
#?(defstruct* (hoge (:conc-name "hoge-")) ; <— use string.
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor |hoge-BAR|))) ; <— This! (defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
Examples of :constructor option.

“‘lisp
#?(defstruct* (hoge (:constructor make)) ; <— Specify.
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make ; <— This!
(&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘

“‘lisp
#?(defstruct* (hoge (:constructor)) ; <— No arg means use default. bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge ; <— This!
(&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘

“‘lisp
#?(defstruct* (hoge (:constructor create-hoge
(a &optional b (c ’sea) &rest d &aux e (f ’eff))))
a b c d e f)
:expanded-to (progn (defclass hoge ()
((a :initform nil :initarg :a :accessor hoge-a)
(b :initform nil :initarg :b :accessor hoge-b)
(c :initform nil :initarg :c :accessor hoge-c)
(d :initform nil :initarg :d :accessor hoge-d)
(e :initform nil :initarg :e :accessor hoge-e)
(f :initform nil :initarg :f :accessor hoge-f)))
;; This!
(defun create-hoge (a &optional b (c ’sea) &rest d &aux e (f ’eff)) (make-instance ’hoge :a a :b b :c c :d d :e e :f f))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
Examples of :copier option.

“‘lisp
#?(defstruct* (hoge (:copier nil)) ; specify nil.
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
;; No cpier!
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘

“‘lisp
#?(defstruct* (hoge (:copier hoge)) ; specify name.
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
;; This!
(defgeneric hoge (arg))
;; Also!
(defmethod hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
Examples of :include option.

“‘lisp
#?(defstruct* (hoge (:include foo)) fuga)
:expanded-to (progn (defclass hoge (foo) ; <— This!
((fuga :initform nil :initarg :fuga :accessor hoge-fuga)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
;; These!
(defgeneric hoge-bar (arg))
(defmethod hoge-bar ((arg hoge))
(foo-bar arg))
(defgeneric (setf hoge-bar) (new arg))
(defmethod (setf hoge-bar) (new (arg hoge))
(setf (foo-bar arg) new))
’hoge)
“‘
Some :include options are valid.
Lets say another object bazz.

“‘lisp
#?(defstruct* bazz
(piyo 0 :read-only t))
=> BAZZ
, :lazy
“‘

“‘lisp
#?(defstruct* (hoge (:include foo)
(:include bazz)) ; <— This!
fuga)
:expanded-to (progn (defclass hoge (foo bazz) ; <— This!
((fuga :initform nil :initarg :fuga :accessor hoge-fuga)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
;; These!
(defgeneric hoge-bar (arg))
(defmethod hoge-bar ((arg hoge))
(foo-bar arg))
(defgeneric (setf hoge-bar) (new arg))
(defmethod (setf hoge-bar) (new (arg hoge))
(setf (foo-bar arg) new))
(defgeneric hoge-piyo (arg))
(defmethod hoge-piyo ((arg hoge))
(bazz-piyo arg))
’hoge)
“‘
Slot description example.

“‘lisp
#?(defstruct* (hoge (:include foo (bar 0)))
fuga)
:expanded-to (progn (defclass hoge (foo)
((fuga :initform nil :initarg :fuga :accessor hoge-fuga)) (:default-initargs :bar 0)) ; <— This!
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
(defgeneric hoge-bar (arg))
(defmethod hoge-bar ((arg hoge))
(foo-bar arg))
(defgeneric (setf hoge-bar) (new arg))
(defmethod (setf hoge-bar) (new (arg hoge))
(setf (foo-bar arg) new))
’hoge)
“‘
Examples of :predicate option.

“‘lisp
#?(defstruct* (hoge (:predicate nil)) ; specify nil.
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
;; No predicate!
’hoge)
“‘

“‘lisp
#?(defstruct* (hoge (:predicate hoge)) ; specify name.
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
;; This!
#+(or clisp sbcl)
(defun hoge (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge (arg))
#-(or clisp sbcl)
(defmethod hoge ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
:print-function

“‘lisp
#?(defstruct* (hoge (:print-function printer)) ; <— specify
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
;; This!
(defmethod print-object ((obj hoge) stream)
(printer obj stream *print-level*))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
:print-object

“‘lisp
#?(defstruct* (hoge (:print-object printer)) ; <— specify
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
;; This!
(defmethod print-object ((obj hoge) stream)
(printer obj stream))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘

Package

structure-ext.as-class.

Source

as-class.lisp.


Previous: , Up: Public Interface   [Contents][Index]

5.1.2 Conditions

Condition: missing-symbol

# MISSING-SYMBOL

## Description:

## Class Precedence List: (case in SBCL)
missing-symbol simple-error simple-condition program-error error serious-condition condition slot-object t

## Effective Slots:
FORMAT-CONTROL [Type] T
[READER] simple-condition-format-control
FORMAT-ARGUMENTS [Type] T
[READER] simple-condition-format-arguments

## Notes:

Package

structure-ext.left-arrow-accessors.

Source

left-arrow-accessors.lisp.

Direct superclasses
  • program-error.
  • simple-error.

5.2 Internals


Previous: , Up: Internals   [Contents][Index]

5.2.1 Ordinary functions

Function: accessors (name options)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: accessors (type slots)
Package

structure-ext.left-arrow-accessors.

Source

left-arrow-accessors.lisp.

Function: check (options)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: collect-option (option options)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: conc-name (options class-name)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: constructors (name options)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: copier (name options)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: enslot (slot conc-name)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: left-arrow-names (type slots)
Package

structure-ext.left-arrow-accessors.

Source

left-arrow-accessors.lisp.

Function: may-documentation (doc)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: may-generic (method &optional lambda-list)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: may-initargs (options)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: method-name (conc-name slot-name)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: parse (body)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: predicate (name options)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: print-function (name options)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: slots (slots options class-name)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: slots<=obj (obj)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: super-classes (options)
Package

structure-ext.as-class.

Source

as-class.lisp.

Function: the-defun-forms (left-arrow-names accessors)
Package

structure-ext.left-arrow-accessors.

Source

left-arrow-accessors.lisp.

Function: the-setf-forms (left-arrow-names accessors)
Package

structure-ext.left-arrow-accessors.

Source

left-arrow-accessors.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   A   C   D   E   F   L   M   P   S   T  
Index Entry  Section

A
accessors: Private ordinary functions
accessors: Private ordinary functions

C
check: Private ordinary functions
collect-option: Private ordinary functions
conc-name: Private ordinary functions
constructors: Private ordinary functions
copier: Private ordinary functions

D
define-left-arrow-accessors: Public macros
defstruct*: Public macros

E
enslot: Private ordinary functions

F
Function, accessors: Private ordinary functions
Function, accessors: Private ordinary functions
Function, check: Private ordinary functions
Function, collect-option: Private ordinary functions
Function, conc-name: Private ordinary functions
Function, constructors: Private ordinary functions
Function, copier: Private ordinary functions
Function, enslot: Private ordinary functions
Function, left-arrow-names: Private ordinary functions
Function, may-documentation: Private ordinary functions
Function, may-generic: Private ordinary functions
Function, may-initargs: Private ordinary functions
Function, method-name: Private ordinary functions
Function, parse: Private ordinary functions
Function, predicate: Private ordinary functions
Function, print-function: Private ordinary functions
Function, slots: Private ordinary functions
Function, slots<=obj: Private ordinary functions
Function, super-classes: Private ordinary functions
Function, the-defun-forms: Private ordinary functions
Function, the-setf-forms: Private ordinary functions

L
left-arrow-names: Private ordinary functions

M
Macro, define-left-arrow-accessors: Public macros
Macro, defstruct*: Public macros
may-documentation: Private ordinary functions
may-generic: Private ordinary functions
may-initargs: Private ordinary functions
method-name: Private ordinary functions

P
parse: Private ordinary functions
predicate: Private ordinary functions
print-function: Private ordinary functions

S
slots: Private ordinary functions
slots<=obj: Private ordinary functions
super-classes: Private ordinary functions

T
the-defun-forms: Private ordinary functions
the-setf-forms: Private ordinary functions

Jump to:   A   C   D   E   F   L   M   P   S   T  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables


Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   A   C   F   L   M   P   S  
Index Entry  Section

A
as-class.lisp: The structure-ext․as-class/as-class․lisp file

C
Condition, missing-symbol: Public conditions

F
File, as-class.lisp: The structure-ext․as-class/as-class․lisp file
File, left-arrow-accessors.lisp: The structure-ext․left-arrow-accessors/left-arrow-accessors․lisp file
File, make-instance.lisp: The structure-ext․make-instance/make-instance․lisp file
File, package.lisp: The structure-ext/package․lisp file
File, structure-ext.as-class.asd: The structure-ext․as-class/structure-ext․as-class․asd file
File, structure-ext.asd: The structure-ext/structure-ext․asd file
File, structure-ext.left-arrow-accessors.asd: The structure-ext․left-arrow-accessors/structure-ext․left-arrow-accessors․asd file
File, structure-ext.make-instance.asd: The structure-ext․make-instance/structure-ext․make-instance․asd file

L
left-arrow-accessors.lisp: The structure-ext․left-arrow-accessors/left-arrow-accessors․lisp file

M
make-instance.lisp: The structure-ext․make-instance/make-instance․lisp file
missing-symbol: Public conditions

P
Package, structure-ext: The structure-ext package
Package, structure-ext.as-class: The structure-ext․as-class package
Package, structure-ext.left-arrow-accessors: The structure-ext․left-arrow-accessors package
Package, structure-ext.make-instance: The structure-ext․make-instance package
package.lisp: The structure-ext/package․lisp file

S
structure-ext: The structure-ext system
structure-ext: The structure-ext package
structure-ext.as-class: The structure-ext․as-class system
structure-ext.as-class: The structure-ext․as-class package
structure-ext.as-class.asd: The structure-ext․as-class/structure-ext․as-class․asd file
structure-ext.asd: The structure-ext/structure-ext․asd file
structure-ext.left-arrow-accessors: The structure-ext․left-arrow-accessors system
structure-ext.left-arrow-accessors: The structure-ext․left-arrow-accessors package
structure-ext.left-arrow-accessors.asd: The structure-ext․left-arrow-accessors/structure-ext․left-arrow-accessors․asd file
structure-ext.make-instance: The structure-ext․make-instance system
structure-ext.make-instance: The structure-ext․make-instance package
structure-ext.make-instance.asd: The structure-ext․make-instance/structure-ext․make-instance․asd file
System, structure-ext: The structure-ext system
System, structure-ext.as-class: The structure-ext․as-class system
System, structure-ext.left-arrow-accessors: The structure-ext․left-arrow-accessors system
System, structure-ext.make-instance: The structure-ext․make-instance system

Jump to:   A   C   F   L   M   P   S