EIEIO
EIEIO (“Enhanced Implementation of Emacs Interpreted Objects”) is a CLOS (Common Lisp Object System) compatibility layer for Emacs Lisp. It provides a framework for writing object-oriented applications in Emacs.
This manual documents EIEIO, an object framework for Emacs Lisp.
Copyright © 2007–2013 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover texts being “A GNU Manual,” and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled “GNU Free Documentation License.”(a) The FSF's Back-Cover Text is: “You have the freedom to copy and modify this GNU manual.”
| Quick Start | Quick start for EIEIO. |
| Introduction | Why use EIEIO? Basic overview, samples list. |
| Building Classes | How to write new class structures. |
| Making New Objects | How to construct new objects. |
| Accessing Slots | How to access a slot. |
| Writing Methods | How to write a method. |
| Method Invocation | How methods are invoked. |
| Predicates | Class-p, Object-p, etc-p. |
| Association Lists | List of objects as association lists. |
| Customizing | Customizing objects. |
| Introspection | Looking inside a class. |
| Base Classes | Additional classes you can inherit from. |
| Browsing | Browsing your class lists. |
| Class Values | Displaying information about a class or object. |
| Documentation | Automatically creating texinfo documentation. |
| Default Superclass | The root superclasses. |
| Signals | When you make errors. |
| Naming Conventions | Name your objects in an Emacs friendly way. |
| CLOS compatibility | What are the differences? |
| Wish List | Things about EIEIO that could be improved. |
| GNU Free Documentation License | The license for this documentation. |
| Function Index |
Next: Introduction, Previous: Top, Up: Top
1 Quick Start
EIEIO provides an Object Oriented layer for Emacs Lisp. You can use EIEIO to create classes, methods for those classes, and instances of classes.
Here is a simple example of a class named record, containing
three slots named name, birthday, and phone:
(defclass record () ; No superclasses
((name :initarg :name
:initform ""
:type string
:custom string
:documentation "The name of a person.")
(birthday :initarg :birthday
:initform "Jan 1, 1970"
:custom string
:type string
:documentation "The person's birthday.")
(phone :initarg :phone
:initform ""
:documentation "Phone number."))
"A single record for tracking people I know.")
Each class can have methods, which are defined like this:
(defmethod call-record ((rec record) &optional scriptname)
"Dial the phone for the record REC.
Execute the program SCRIPTNAME to dial the phone."
(message "Dialing the phone for %s" (oref rec name))
(shell-command (concat (or scriptname "dialphone.sh")
" "
(oref rec phone))))
In this example, the first argument to call-record is a list,
of the form (varname classname). varname is the
name of the variable used for the first argument; classname is
the name of the class that is expected as the first argument for this
method.
EIEIO dispatches methods based on the type of the first argument.
You can have multiple methods with the same name for different classes
of object. When the call-record method is called, the first
argument is examined to determine the class of that argument, and the
method matching the input type is then executed.
Once the behavior of a class is defined, you can create a new
object of type record. Objects are created by calling the
constructor. The constructor is a function with the same name as your
class which returns a new instance of that class. Here is an example:
(setq rec (record "Eric" :name "Eric" :birthday "June" :phone "555-5555"))
The first argument is the name given to this instance. Each instance is given a name, so different instances can be easily distinguished when debugging.
It can be a bit repetitive to also have a :name slot. To avoid doing
this, it is sometimes handy to use the base class eieio-named.
See eieio-named.
Calling methods on an object is a lot like calling any function. The first argument should be an object of a class which has had this method defined for it. In this example it would look like this:
(call-record rec)
or
(call-record rec "my-call-script")
In these examples, EIEIO automatically examines the class of
rec, and ensures that the method defined above is called. If
rec is some other class lacking a call-record method, or
some other data type, Emacs signals a no-method-definition
error. Signals.
Next: Building Classes, Previous: Quick Start, Up: Top
2 Introduction
Due to restrictions in the Emacs Lisp language, CLOS cannot be completely supported, and a few functions have been added in place of setf.
EIEIO supports the following features:
- A structured framework for the creation of basic classes with attributes and methods using singular inheritance similar to CLOS.
- Type checking, and slot unbinding.
- Method definitions similar to CLOS.
- Simple and complex class browsers.
- Edebug support for methods.
- Imenu updates.
- Byte compilation support of methods.
- Help system extensions for classes and methods.
- Automatic texinfo documentation generator.
- Several base classes for interesting tasks.
- Simple test suite.
- Public and private classifications for slots (extensions to CLOS)
- Customization support in a class (extension to CLOS)
Here are some CLOS features that EIEIO presently lacks:
- Complete
defclasstag support - All CLOS tags are currently supported, but the following are not
currently implemented correctly:
:metaclass- There is only one base superclass for all EIEIO classes, which is
the
eieio-default-superclass. :default-initargs- Each slot has an
:initargtag, so this is not really necessary.
- Mock object initializers
- Each class contains a mock object used for fast initialization of
instantiated objects. Using functions with side effects on object slot
values can potentially cause modifications in the mock object. EIEIO
should use a deep copy but currently does not.
:aroundmethod tag- This CLOS method tag is non-functional.
Next: Making New Objects, Previous: Introduction, Up: Top
3 Building Classes
A class is a definition for organizing data and methods together. An EIEIO class has structures similar to the classes found in other object-oriented (OO) languages.
To create a new class, use the defclass macro:
Create a new class named class-name. The class is represented by a self-referential symbol with the name class-name. EIEIO stores the structure of the class as a symbol property of class-name (see Symbol Components).
The class-name symbol's variable documentation string is a modified version of the doc string found in options-and-doc. Each time a method is defined, the symbol's documentation string is updated to include the methods documentation as well.
The parent classes for class-name is superclass-list. Each element of superclass-list must be a class. These classes are the parents of the class being created. Every slot that appears in each parent class is replicated in the new class.
If two parents share the same slot name, the parent which appears in the superclass-list first sets the tags for that slot. If the new class has a slot with the same name as the parent, the new slot overrides the parent's slot.
When overriding a slot, some slot attributes cannot be overridden because they break basic OO rules. You cannot override
:typeor:protection.
Whenever defclass is used to create a new class, two predicates are
created for it, named CLASS-NAME-p and
CLASS-NAME-child-p:
Return
tif OBJECT is of the class CLASS-NAME, or is of a subclass of CLASS-NAME.
If non-nil,
defclasssignals an error if a tag in a slot specifier is unsupported.This option is here to support programs written with older versions of EIEIO, which did not produce such errors.
Next: Slot Options, Up: Building Classes
3.1 Inheritance
Inheritance is a basic feature of an object-oriented language.
In EIEIO, a defined class specifies the super classes from which it
inherits by using the second argument to defclass. Here is an
example:
(defclass my-baseclass ()
((slot-A :initarg :slot-A)
(slot-B :initarg :slot-B))
"My Baseclass.")
To subclass from my-baseclass, we specify it in the superclass
list:
(defclass my-subclass (my-baseclass)
((specific-slot-A :initarg specific-slot-A)
)
"My subclass of my-baseclass")
Instances of my-subclass will inherit slot-A and
slot-B, in addition to having specific-slot-A from the
declaration of my-subclass.
EIEIO also supports multiple inheritance. Suppose we define a second baseclass, perhaps an “interface” class, like this:
(defclass my-interface ()
((interface-slot :initarg :interface-slot))
"An interface to special behavior."
:abstract t)
The interface class defines a special interface-slot, and also
specifies itself as abstract. Abstract classes cannot be
instantiated. It is not required to make interfaces abstract, but it
is a good programming practice.
We can now modify our definition of my-subclass to use this
interface class, together with our original base class:
(defclass my-subclass (my-baseclass my-interface)
((specific-slot-A :initarg specific-slot-A)
)
"My subclass of my-baseclass")
With this, my-subclass also has interface-slot.
If my-baseclass and my-interface had slots with the same
name, then the superclass showing up in the list first defines the
slot attributes.
Inheritance in EIEIO is more than just combining different slots. It is also important in method invocation. Methods.
If a method is called on an instance of my-subclass, and that
method only has an implementation on my-baseclass, or perhaps
my-interface, then the implementation for the baseclass is
called.
If there is a method implementation for my-subclass, and
another in my-baseclass, the implementation for
my-subclass can call up to the superclass as well.
Next: Class Options, Previous: Inheritance, Up: Building Classes
3.2 Slot Options
The slot-list argument to defclass is a list of elements
where each element defines one slot. Each slot is a list of the form
(SLOT-NAME :TAG1 ATTRIB-VALUE1
:TAG2 ATTRIB-VALUE2
:TAGN ATTRIB-VALUEN)
where SLOT-NAME is a symbol that will be used to refer to the slot. :TAG is a symbol that describes a feature to be set on the slot. ATTRIB-VALUE is a lisp expression that will be used for :TAG.
Valid tags are:
:initarg- A symbol that can be used in the argument list of the constructor to
specify a value for the new instance being created.
A good symbol to use for initarg is one that starts with a colon
:.The slot specified like this:
(myslot :initarg :myslot)
could then be initialized to the number 1 like this:
(myobject "name" :myslot 1)
See Making New Objects.
:initform- A expression used as the default value for this slot.
If
:initformis left out, that slot defaults to being unbound. It is an error to reference an unbound slot, so if you need slots to always be in a bound state, you should always use an:initformspecifier.Use
slot-boundpto test if a slot is unbound (see Predicates). Useslot-makeunboundto set a slot to being unbound after giving it a value (see Accessing Slots).The value passed to initform is automatically quoted. Thus,
:initform (1 2 3)
appears as the specified list in the default object. A symbol that is a function like this:
:initform +
will set the initial value as that symbol.
After a class has been created with
defclass, you can change that default value withoset-default. Accessing Slots. :type- An unquoted type specifier used to validate data set into this slot.
See Type Predicates.
Here are some examples:
symbol- A symbol.
number- A number type
my-class-name- An object of your class type.
(or null symbol)- A symbol, or nil.
:allocation- Either :class or :instance (defaults to :instance) used to
specify how data is stored. Slots stored per instance have unique
values for each object. Slots stored per class have shared values for
each object. If one object changes a :class allocated slot, then all
objects for that class gain the new value.
:documentation- Documentation detailing the use of this slot. This documentation is
exposed when the user describes a class, and during customization of an
object.
:accessor- Name of a generic function which can be used to fetch the value of this slot.
You can call this function later on your object and retrieve the value
of the slot.
This options is in the CLOS spec, but is not fully compliant in EIEIO.
:writer- Name of a generic function which will write this slot.
This options is in the CLOS spec, but is not fully compliant in EIEIO.
:reader- Name of a generic function which will read this slot.
This options is in the CLOS spec, but is not fully compliant in EIEIO.
:custom- A custom :type specifier used when editing an object of this type.
See documentation for
defcustomfor details. This specifier is equivalent to the :type spec of adefcustomcall.This options is specific to Emacs, and is not in the CLOS spec.
:label- When customizing an object, the value of :label will be used instead
of the slot name. This enables better descriptions of the data than
would usually be afforded.
This options is specific to Emacs, and is not in the CLOS spec.
:group- Similar to
defcustom's :group command, this organizes different slots in an object into groups. When customizing an object, only the slots belonging to a specific group need be worked with, simplifying the size of the display.This options is specific to Emacs, and is not in the CLOS spec.
:printer- This routine takes a symbol which is a function name. The function
should accept one argument. The argument is the value from the slot
to be printed. The function in
object-writewill write the slot value out to a printable form onstandard-output.The output format MUST be something that could in turn be interpreted with
readsuch that the object can be brought back in from the output stream. Thus, if you wanted to output a symbol, you would need to quote the symbol. If you wanted to run a function on load, you can output the code to do the construction of the value. :protection- When using a slot referencing function such as
slot-value, and the value behind slot is private or protected, then the current scope of operation must be within a method of the calling object.Valid values are:
:public- Access this slot from any scope.
:protected- Access this slot only from methods of the same class or a child class.
:private- Access this slot only from methods of the same class.
This options is specific to Emacs, and is not in the CLOS spec.
Previous: Slot Options, Up: Building Classes
3.3 Class Options
In the options-and-doc arguments to defclass, the
following class options may be specified:
:documentation- A documentation string for this class.
If an Emacs-style documentation string is also provided, then this option is ignored. An Emacs-style documentation string is not prefixed by the
:documentationtag, and appears after the list of slots, and before the options. :allow-nil-initform- If this option is non-nil, and the
:initformisnil, but the:typeis specifies something such asstringthen allow this to pass. The default is to have this option be off. This is implemented as an alternative to unbound slots.This options is specific to Emacs, and is not in the CLOS spec.
:abstract- A class which is
:abstractcannot be instantiated, and instead is used to define an interface which subclasses should implement.This option is specific to Emacs, and is not in the CLOS spec.
:custom-groups- This is a list of groups that can be customized within this class. This
slot is auto-generated when a class is created and need not be
specified. It can be retrieved with the
class-optioncommand, however, to see what groups are available.This option is specific to Emacs, and is not in the CLOS spec.
:method-invocation-order- This controls the order in which method resolution occurs for
:primarymethods in cases of multiple inheritance. The order affects which method is called first in a tree, and ifcall-next-methodis used, it controls the order in which the stack of methods are run.Valid values are:
:breadth-first- Search for methods in the class hierarchy in breadth first order.
This is the default.
:depth-first- Search for methods in the class hierarchy in a depth first order.
:c3- Searches for methods in in a linearized way that most closely matches what CLOS does when a monotonic class structure is defined.
See Method Invocation, for more on method invocation order.
:metaclass- Unsupported CLOS option. Enables the use of a different base class other
than
standard-class. :default-initargs- Unsupported CLOS option. Specifies a list of initargs to be used when
creating new objects. As far as I can tell, this duplicates the
function of
:initform.
See CLOS compatibility, for more details on CLOS tags versus EIEIO-specific tags.
Next: Accessing Slots, Previous: Building Classes, Up: Top
4 Making New Objects
Suppose we have a simple class is defined, such as:
(defclass record ()
( ) "Doc String")
It is now possible to create objects of that class type.
Calling defclass has defined two new functions. One is the
constructor record, and the other is the predicate,
record-p.
This creates and returns a new object. This object is not assigned to anything, and will be garbage collected if not saved. This object will be given the string name object-name. There can be multiple objects of the same name, but the name slot provides a handy way to keep track of your objects. slots is just all the slots you wish to preset. Any slot set as such will not get its default value, and any side effects from a slot's
:initformthat may be a function will not occur.An example pair would appear simply as
:value 1. Of course you can do any valid Lispy thing you want with it, such as:value (if (boundp 'special-symbol) special-symbol nil)Example of creating an object from a class:
(record "test" :value 3 :reference nil)
To create an object from a class symbol, use make-instance.
Make a new instance of class based on initargs. class is a class symbol. For example:
(make-instance 'foo)initargs is a property list with keywords based on the
:initargfor each slot. For example:(make-instance'foo:slot1value1:slotNvalueN)Compatibility note:
If the first element of initargs is a string, it is used as the name of the class.
In EIEIO, the class' constructor requires a name for use when printing. make-instance in CLOS doesn't use names the way Emacs does, so the class is used as the name slot instead when initargs doesn't start with a string.
Next: Writing Methods, Previous: Making New Objects, Up: Top
5 Accessing Slots
There are several ways to access slot values in an object. The naming and argument-order conventions are similar to those used for referencing vectors (see Vectors).
This macro sets the value behind slot to value in object. It returns value.
This macro sets the
:initformfor slot in class to value.This allows the user to set both public and private defaults after the class has been constructed, and provides a way to configure the default behavior of packages built with classes (the same way
setq-defaultdoes for buffer-local variables).For example, if a user wanted all
data-objects(see Building Classes) to inform a special object of his own devising when they changed, this can be arranged by simply executing this bit of code:(oset-default data-object reference (list my-special-object))
Retrieve the value stored in obj in the slot named by slot. Slot is the name of the slot when created by defclass or the label created by the
:initargtag.
Gets the default value of obj (maybe a class) for slot. The default value is the value installed in a class with the
:initformtag. slot can be the slot name, or the tag specified by the:initargtag in the defclass call.
The following accessors are defined by CLOS to reference or modify slot values, and use the previously mentioned set/ref routines.
This function retrieves the value of slot from object. Unlike
oref, the symbol for slot must be quoted.
This is not a CLOS function, but is meant to mirror
slot-valueif you don't want to use the cl package'ssetffunction. This function sets the value of slot from object. Unlikeoset, the symbol for slot must be quoted.
This function unbinds slot in object. Referencing an unbound slot can signal an error.
In OBJECT's slot, add item to the list of elements. Optional argument append indicates we need to append to the list. If item already exists in the list in slot, then it is not added. Comparison is done with equal through the member function call. If slot is unbound, bind it to the list containing item.
In OBJECT's slot, remove occurrences of item. Deletion is done with delete, which deletes by side effect and comparisons are done with equal. If slot is unbound, do nothing.
Bind spec-list lexically to slot values in object, and execute body. This establishes a lexical environment for referring to the slots in the instance named by the given slot-names as though they were variables. Within such a context the value of the slot can be specified by using its slot name, as if it were a lexically bound variable. Both setf and setq can be used to set the value of the slot.
spec-list is of a form similar to let. For example:
((VAR1 SLOT1) SLOT2 SLOTN (VARN+1 SLOTN+1))Where each var is the local variable given to the associated slot. A slot specified without a variable name is given a variable name of the same name as the slot.
(defclass myclass () (x :initarg 1)) (setq mc (make-instance 'myclass)) (with-slots (x) mc x) => 1 (with-slots ((something x)) mc something) => 1
Next: Method Invocation, Previous: Accessing Slots, Up: Top
6 Writing Methods
Writing a method in EIEIO is similar to writing a function. The differences are that there are some extra options and there can be multiple definitions under the same function symbol.
Where a method defines an implementation for a particular data type, a generic method accepts any argument, but contains no code. It is used to provide the dispatching to the defined methods. A generic method has no body, and is merely a symbol upon which methods are attached. It also provides the base documentation for what methods with that name do.
Next: Methods, Up: Writing Methods
6.1 Generics
Each EIEIO method has one corresponding generic. This generic provides a function binding and the base documentation for the method symbol (see Symbol Components).
This macro turns the (unquoted) symbol method into a function. arglist is the default list of arguments to use (not implemented yet). doc-string is the documentation used for this symbol.
A generic function acts as a placeholder for methods. There is no need to call
defgenericyourself, asdefmethodwill call it if necessary. Currently the argument list is unused.
defgenericsignals an error if you attempt to turn an existing Emacs Lisp function into a generic function.You can also create a generic method with
defmethod(see Methods). When a method is created and there is no generic method in place with that name, then a new generic will be created, and the new method will use it.
In CLOS, a generic call also be used to provide an argument list and dispatch precedence for all the arguments. In EIEIO, dispatching only occurs for the first argument, so the arglist is not used.
Next: Static Methods, Previous: Generics, Up: Writing Methods
6.2 Methods
A method is a function that is executed if the first argument passed to it matches the method's class. Different EIEIO classes may share the same method names.
Methods are created with the defmethod macro, which is similar
to defun.
method is the name of the function to create.
:beforeand:afterspecify execution order (i.e., when this form is called). If neither of these symbols are present, the default priority is used (before:afterand after:before); this default priority is represented in CLOS as:primary.Note: The
:BEFORE,:PRIMARY,:AFTER, and:STATICmethod tags were in all capital letters in previous versions of EIEIO.arglist is the list of arguments to this method. The first argument in this list—and only the first argument—may have a type specifier (see the example below). If no type specifier is supplied, the method applies to any object.
doc-string is the documentation attached to the implementation. All method doc-strings are incorporated into the generic method's function documentation.
forms is the body of the function.
In the following example, we create a method mymethod for the
classname class:
(defmethod mymethod ((obj classname) secondarg)
"Doc string" )
This method only executes if the obj argument passed to it is an
EIEIO object of class classname.
A method with no type specifier is a default method. If a given class has no implementation, then the default method is called when that method is used on a given object of that class.
Only one default method per execution specifier (:before,
:primary, or :after) is allowed. If two
defmethods appear with arglists lacking a type specifier,
and having the same execution specifier, then the first implementation
is replaced.
When a method is called on an object, but there is no method specified
for that object, but there is a method specified for object's parent
class, the parent class' method is called. If there is a method
defined for both, only the child's method is called. A child method
may call a parent's method using call-next-method, described
below.
If multiple methods and default methods are defined for the same method and class, they are executed in this order:
- method :before
- default :before
- method :primary
- default :primary
- method :after
- default :after
If no methods exist, Emacs signals a no-method-definition
error. See Signals.
This function calls the superclass method from a subclass method. This is the “next method” specified in the current method list.
If replacement-args is non-
nil, then use them instead ofeieio-generic-call-arglst. At the top level, the generic argument list is passed in.Use
next-method-pto find out if there is a next method to call.
Non-
nilif there is a next method. Returns a list of lambda expressions which is thenext-methodorder.
At present, EIEIO does not implement all the features of CLOS:
- There is currently no
:aroundtag. - CLOS allows multiple sets of type-cast arguments, but EIEIO only allows the first argument to be cast.
Previous: Methods, Up: Writing Methods
6.3 Static Methods
Static methods do not depend on an object instance, but instead
operate on an object's class. You can create a static method by using
the :static key with defmethod.
Do not treat the first argument of a :static method as an
object unless you test it first. Use the functions
oref-default or oset-default which will work on a class,
or on the class of an object.
A Class' constructor method is defined as a :static
method.
Note: The :static keyword is unique to EIEIO.
Next: Predicates, Previous: Writing Methods, Up: Top
7 Method Invocation
When classes are defined, you can specify the
:method-invocation-order. This is a feature specific to EIEIO.
This controls the order in which method resolution occurs for
:primary methods in cases of multiple inheritance. The order
affects which method is called first in a tree, and if
call-next-method is used, it controls the order in which the
stack of methods are run.
The original EIEIO order turned out to be broken for multiple inheritance, but some programs depended on it. As such this option was added when the default invocation order was fixed to something that made more sense in that case.
Valid values are:
:breadth-first- Search for methods in the class hierarchy in breadth first order.
This is the default.
:depth-first- Search for methods in the class hierarchy in a depth first order.
:c3- Searches for methods in in a linearized way that most closely matches
what CLOS does when CLOS when a monotonic class structure is defined.
This is derived from the Dylan language documents by Kim Barrett et al.: A Monotonic Superclass Linearization for Dylan Retrieved from: http://192.220.96.201/dylan/linearization-oopsla96.html
Next: Association Lists, Previous: Method Invocation, Up: Top
8 Predicates and Utilities
Now that we know how to create classes, access slots, and define methods, it might be useful to verify that everything is doing ok. To help with this a plethora of predicates have been created.
Return the class that symbol represents. If there is no class,
nilis returned if errorp isnil. If errorp is non-nil,wrong-argument-typeis signaled.
Non-
nilif OBJECT's slot is bound. Setting a slot's value makes it bound. Calling slot-makeunbound will make a slot unbound. object can be an instance or a class.
Return a string of the form ‘#<class myclassname>’ which should look similar to other Lisp objects like buffers and processes. Printing a class results only in a symbol.
Return the value in CLASS of a given OPTION. For example:
(class-option eieio-default-superclass :documentation)Will fetch the documentation string for
eieio-default-superclass.
Return a symbol used as a constructor for class. The constructor is a function used to create new instances of CLASS. This function provides a way to make an object of a class without knowing what it is. This is not a part of CLOS.
Return a string of the form ‘#<object-class myobjname>’ for obj. This should look like Lisp symbols from other parts of Emacs such as buffers and processes, and is shorter and cleaner than printing the object's vector. It is more useful to use
object-printto get and object's print form, as this allows the object to add extra display information into the symbol.
Same as
object-classexcept this is a macro, and no type-checking is performed.
Returns the direct parents class of class. Returns
nilif it is a superclass.
Just like
class-parentexcept it is a macro and no type checking is performed.
Same as
same-class-pexcept this is a macro and no type checking is performed.
Returns
tif obj inherits anything from class. This is different fromsame-class-pbecause it checks for inheritance.
Returns
tifmethod-symbolis a generic function, as opposed to a regular Emacs Lisp function.
Next: Customizing, Previous: Predicates, Up: Top
9 Association Lists
Lisp offers the concept of association lists, with primitives such as
assoc used to access them. The following functions can be used
to manage association lists of EIEIO objects:
Return an object if key is equal to SLOT's value of an object in list. list is a list of objects whose slots are searched. Objects in list do not need to have a slot named slot, nor does slot need to be bound. If these errors occur, those objects will be ignored.
Return an association list generated by extracting slot from all objects in list. For each element of list the
caris the value of slot, and thecdris the object it was extracted from. This is useful for generating completion tables.
Returns an alist of all currently defined classes. This alist is suitable for completion lists used by interactive functions to select a class. The optional argument base-class allows the programmer to select only a subset of classes which includes base-class and all its subclasses.
Next: Introspection, Previous: Association Lists, Up: Top
10 Customizing Objects
EIEIO supports the Custom facility through two new widget types.
If a variable is declared as type object, then full editing of
slots via the widgets is made possible. This should be used
carefully, however, because modified objects are cloned, so if there
are other references to these objects, they will no longer be linked
together.
If you want in place editing of objects, use the following methods:
Create a custom buffer and insert a widget for editing object. At the end, an
ApplyandResetbutton are available. This will edit the object "in place" so references to it are also changed. There is no effort to prevent multiple edits of a singular object, so care must be taken by the user of this function.
This method inserts an edit object into the current buffer in place. It is implemented as
(widget-create 'object-edit :value object). This method is provided as a locale for adding tracking, or specializing the widget insert procedure for any object.
To define a slot with an object in it, use the object tag. This
widget type will be automatically converted to object-edit if you
do in place editing of you object.
If you want to have additional actions taken when a user clicks on the
Apply button, then overload the method eieio-done-customizing.
This method does nothing by default, but that may change in the future.
This would be the best way to make your objects persistent when using
in-place editing.
10.1 Widget extension
When widgets are being created, one new widget extension has been added,
called the :slotofchoices. When this occurs in a widget
definition, all elements after it are removed, and the slot is specifies
is queried and converted into a series of constants.
(choice (const :tag "None" nil)
:slotofchoices morestuff)
and if the slot morestuff contains (sym1 sym2 sym3), the
above example is converted into:
(choice (const :tag "None" nil)
(const sym1)
(const sym2)
(const sym3))
This is useful when a given item needs to be selected from a list of items defined in this second slot.
Next: Base Classes, Previous: Customizing, Up: Top
11 Introspection
Introspection permits a programmer to peek at the contents of a class without any previous knowledge of that class. While EIEIO implements objects on top of vectors, and thus everything is technically visible, some functions have been provided. None of these functions are a part of CLOS.
For the given class return the :initarg associated with slot. Not all slots have initargs, so the return value can be nil.
Next: Browsing, Previous: Introspection, Up: Top
12 Base Classes
All defined classes, if created with no specified parent class,
inherit from a special class called eieio-default-superclass.
See Default Superclass.
Often, it is more convenient to inherit from one of the other base classes provided by EIEIO, which have useful pre-defined properties. (Since EIEIO supports multiple inheritance, you can even inherit from more than one of these classes at once.)
12.1 eieio-instance-inheritor
This class is defined in the package eieio-base.
Instance inheritance is a mechanism whereby the value of a slot in object instance can reference the parent instance. If the parent's slot value is changed, then the child instance is also changed. If the child's slot is set, then the parent's slot is not modified.
A class whose instances are enabled with instance inheritance. The parent-instance slot indicates the instance which is considered the parent of the current instance. Default is
nil.
To use this class, inherit from it with your own class.
To make a new instance that inherits from and existing instance of your
class, use the clone method with additional parameters
to specify local values.
The eieio-instance-inheritor class works by causing cloned
objects to have all slots unbound. This class' slot-unbound
method will cause references to unbound slots to be redirected to the
parent instance. If the parent slot is also unbound, then
slot-unbound will signal an error named slot-unbound.
12.2 eieio-instance-tracker
This class is defined in the package eieio-base.
Sometimes it is useful to keep a master list of all instances of a given
class. The class eieio-instance-tracker performs this task.
Enable instance tracking for this class. The slot tracker-symbol should be initialized in inheritors of this class to a symbol created with
defvar. This symbol will serve as the variable used as a master list of all objects of the given class.
This method is defined as an
:aftermethod. It adds new instances to the master list. Do not overload this method unless you usecall-next-method.
Remove obj from the master list of instances of this class. This may let the garbage collector nab this instance.
This convenience function lets you find instances. key is the value to search for. slot is the slot to compare KEY against. The function
equalis used for comparison. The parameter list-symbol is the variable symbol which contains the list of objects to be searched.
12.3 eieio-singleton
This class is defined in the package eieio-base.
Inheriting from the singleton class will guarantee that there will only ever be one instance of this class. Multiple calls to
make-instancewill always return the same object.
12.4 eieio-persistent
This class is defined in the package eieio-base.
If you want an object, or set of objects to be persistent, meaning the
slot values are important to keep saved between sessions, then you will
want your top level object to inherit from eieio-persistent.
To make sure your persistent object can be moved, make sure all file
names stored to disk are made relative with
eieio-persistent-path-relative.
Enables persistence for instances of this class. Slot file with initarg
:fileis the file name in which this object will be saved. Class allocated slot file-header-line is used with methodobject-writeas a header comment.
All objects can write themselves to a file, but persistent objects have several additional methods that aid in maintaining them.
Write the object obj to its file. If optional argument file is specified, use that file name instead.
Return a file name derived from file which is relative to the stored location of OBJ. This method should be used to convert file names so that they are relative to the save file, making any system of files movable from one location to another.
Like
object-writeforstandard-object, but will derive a header line comment from the class allocated slot if one is not provided.
Read a persistent object from filename, and return it. Signal an error if the object in FILENAME is not a constructor for CLASS. Optional allow-subclass says that it is ok for
eieio-persistent-readto load in subclasses of class instead of being pedantic.
12.5 eieio-named
This class is defined in the package eieio-base.
Object with a name. Name storage already occurs in an object. This object provides get/set access to it.
12.6 eieio-speedbar
This class is in package eieio-speedbar.
If a series of class instances map to a tree structure, it is possible to cause your classes to be displayable in Speedbar. See Top. Inheriting from these classes will enable a speedbar major display mode with a minimum of effort.
Enables base speedbar display for a class. The slot buttontype is any of the symbols allowed by the function
speedbar-make-tag-linefor the exp-button-type argument See Extending. The slot buttonface is the face to use for the text of the string displayed in speedbar. The slots buttontype and buttonface are class allocated slots, and do not take up space in your instances.
This class inherits from
eieio-speedbarand initializes buttontype and buttonface to appear as directory level lines.
This class inherits from
eieio-speedbarand initializes buttontype and buttonface to appear as file level lines.
To use these classes, inherit from one of them in you class. You can use multiple inheritance with them safely. To customize your class for speedbar display, override the default values for buttontype and buttonface to get the desired effects.
Useful methods to define for your new class include:
Return a string representing a directory associated with an instance of obj. depth can be used to index how many levels of indentation have been opened by the user where obj is shown.
Return a string description of OBJ. This is shown in the minibuffer or tooltip when the mouse hovers over this instance in speedbar.
Return a string representing a description of a child node of obj when that child is not an object. It is often useful to just use item info helper functions such as
speedbar-item-info-file-helper.
Return a string which is the text displayed in speedbar for obj.
This method inserts a list of speedbar tag lines for obj to represent its children. Implement this method for your class if your children are not objects themselves. You still need to implement
eieio-speedbar-object-children.In this method, use techniques specified in the Speedbar manual. See Extending.
Some other functions you will need to learn to use are:
Register your object display mode with speedbar. make-map is a function which initialized you keymap. key-map is a symbol you keymap is installed into. menu is an easy menu vector representing menu items specific to your object display. name is a short string to use as a name identifying you mode. toplevelfn is a function called which must return a list of objects representing those in the instance system you wish to browse in speedbar.
Read the Extending chapter in the speedbar manual for more information on how speedbar modes work See Extending.
Next: Class Values, Previous: Base Classes, Up: Top
13 Browsing class trees
The command M-x eieio-browse displays a buffer listing all the
currently loaded classes in Emacs. The classes are listed in an
indented tree structure, starting from eieio-default-superclass
(see Default Superclass).
With a prefix argument, this command prompts for a class name; it then lists only that class and its subclasses.
Here is a sample tree from our current example:
eieio-default-superclass
+--data-object
+--data-object-symbol
Note: new classes are consed into the inheritance lists, so the tree comes out upside-down.
Next: Documentation, Previous: Browsing, Up: Top
14 Class Values
Details about any class or object can be retrieved using the function
eieio-describe-class. Interactively, type in the name of
a class. In a program, pass it a string with the name of a class, a
class symbol, or an object. The resulting buffer will display all slot
names.
Additionally, all methods defined to have functionality on this class is displayed.
Next: Default Superclass, Previous: Class Values, Up: Top
15 Documentation
It is possible to automatically create documentation for your classes in texinfo format by using the tools in the file eieio-doc.el
This will start at the current point, and create an indented menu of all the child classes of, and including class, but skipping any classes that might be in skiplist. It will then create nodes for all these classes, subsection headings, and indexes.
Each class will be indexed using the texinfo labeled index indexstring which is a two letter description. See New Indices.
To use this command, the texinfo macro
@defindex @var { indexstring }where indexstring is replaced with the two letter code.
Next, an inheritance tree will be created listing all parents of that section's class.
Then, all the slots will be expanded in tables, and described using the documentation strings from the code. Default values will also be displayed. Only those slots with
:initargspecified will be expanded, others will be hidden. If a slot is inherited from a parent, that slot will also be skipped unless the default value is different. If there is a change, then the documentation part of the slot will be replace with an @xref back to the parent.This command can only display documentation for classes whose definitions have been loaded in this Emacs session.
Next: Signals, Previous: Documentation, Up: Top
16 Default Superclass
All defined classes, if created with no specified parent class, will
inherit from a special class stored in
eieio-default-superclass. This superclass is quite simple, but
with it, certain default methods or attributes can be added to all
objects. In CLOS, this would be named STANDARD-CLASS, and that
symbol is an alias to eieio-default-superclass.
Currently, the default superclass is defined as follows:
(defclass eieio-default-superclass nil
nil
"Default parent class for classes with no specified parent class.
Its slots are automatically adopted by classes with no specified
parents. This class is not stored in the `parent' slot of a class vector."
:abstract t)
The default superclass implements several methods providing a default behavior for all objects created by EIEIO.
Next: Basic Methods, Up: Default Superclass
16.1 Initialization
When creating an object of any type, you can use its constructor, or
make-instance. This, in turns calls the method
initialize-instance, which then calls the method
shared-initialize.
These methods are all implemented on the default superclass so you do not need to write them yourself, unless you need to override one of their behaviors.
Users should not need to call initialize-instance or
shared-initialize, as these are used by make-instance to
initialize the object. They are instead provided so that users can
augment these behaviors.
Initialize obj. Sets slots of obj with slots which is a list of name/value pairs. These are actually just passed to
shared-initialize.
Sets slots of obj with slots which is a list of name/value pairs.
This is called from the default
constructor.
Next: Signal Handling, Previous: Initialization, Up: Default Superclass
16.2 Basic Methods
Additional useful methods defined on the base subclass are:
Make a copy of obj, and then apply params. params is a parameter list of the same form as initialize-instance which are applied to change the object. When overloading clone, be sure to call call-next-method first and modify the returned object.
Pretty printer for object this. Call function object-name with strings. The default method for printing object this is to use the function object-name.
It is sometimes useful to put a summary of the object into the default #<notation> string when using eieio browsing tools.
Implement this function and specify strings in a call to call-next-method to provide additional summary information. When passing in extra strings from child classes, always remember to prepend a space.
(defclass data-object () (value) "Object containing one data slot.") (defmethod object-print ((this data-object) &optional strings) "Return a string with a summary of the data object as part of the name." (apply 'call-next-method this (cons (format " value: %s" (render this)) strings)))Here is what some output could look like:
(object-print test-object) => #<data-object test-object value: 3>
Write obj onto a stream in a readable fashion. The resulting output will be Lisp code which can be used with
readandevalto recover the object. Only slots with:initargs are written to the stream.
Previous: Basic Methods, Up: Default Superclass
16.3 Signal Handling
The default superclass defines methods for managing error conditions. These methods all throw a signal for a particular error condition.
By implementing one of these methods for a class, you can change the behavior that occurs during one of these error cases, or even ignore the error by providing some behavior.
Method invoked when an attempt to access a slot in object fails. slot-name is the name of the failed slot, operation is the type of access that was requested, and optional new-value is the value that was desired to be set.
This method is called from
oref,oset, and other functions which directly reference slots in EIEIO objects.The default method signals an error of type
invalid-slot-name. See Signals.You may override this behavior, but it is not expected to return in the current implementation.
This function takes arguments in a different order than in CLOS.
Slot unbound is invoked during an attempt to reference an unbound slot. object is the instance of the object being reference. class is the class of object, and slot-name is the offending slot. This function throws the signal
unbound-slot. You can overload this function and return the value to use in place of the unbound value. Argument fn is the function signaling this error. Use slot-boundp to determine if a slot is bound or not.In clos, the argument list is (class object slot-name), but eieio can only dispatch on the first argument, so the first two are swapped.
Called if there are no implementations for object in method. object is the object which has no method implementation. args are the arguments that were passed to method.
Implement this for a class to block this signal. The return value becomes the return value of the original method call.
Called from call-next-method when no additional methods are available. object is othe object being called on call-next-method. args are the arguments it is called by. This method signals no-next-method by default. Override this method to not throw an error, and its return value becomes the return value of call-next-method.
Next: Naming Conventions, Previous: Default Superclass, Up: Top
17 Signals
There are new condition names (signals) that can be caught when using EIEIO.
This signal is called when an attempt to reference a slot in an obj-or-class is made, and the slot is not defined for it.
This signal is called when method is called, with arguments and nothing is resolved. This occurs when method has been defined, but the arguments make it impossible for EIEIO to determine which method body to run.
To prevent this signal from occurring in your class, implement the method
no-applicable-methodfor your class. This method is called when to throw this signal, so implementing this for your class allows you block the signal, and perform some work.
This signal is called if the function
call-next-methodis called and there is no next method to be called.Overload the method
no-next-methodto protect against this signal.
This signal is called when an attempt to set slot is made, and value doesn't match the specified type spec.
In EIEIO, this is also used if a slot specifier has an invalid value during a
defclass.
This signal is called when an attempt to reference slot in object is made, and that instance is currently unbound.
Next: CLOS compatibility, Previous: Signals, Up: Top
18 Naming Conventions
See Tips and Conventions, for a description of Emacs Lisp programming conventions. These conventions help ensure that Emacs packages work nicely one another, so an EIEIO-based program should follow them. Here are some conventions that apply specifically to EIEIO-based programs:
- Come up with a package prefix that is relatively short. Prefix all classes, and methods with your prefix. This is a standard convention for functions and variables in Emacs.
- Do not prefix method names with the class name. All methods in EIEIO are “virtual”, and are dynamically dispatched. Anyone can override your methods at any time. Your methods should be prefixed with your package name.
- Do not prefix slots in your class. The slots are always locally scoped to your class, and need no prefixing.
- If your library inherits from other libraries of classes, you
must “require” that library with the
requirecommand.
Next: Wish List, Previous: Naming Conventions, Up: Top
19 CLOS compatibility
Currently, the following functions should behave almost as expected from CLOS.
defclass- All slot keywords are available but not all work correctly.
Slot keyword differences are:
- :reader, and :writer tags
- Create methods that signal errors instead of creating an unqualified
method. You can still create new ones to do its business.
- :accessor
- This should create an unqualified method to access a slot, but
instead pre-builds a method that gets the slot's value.
- :type
- Specifier uses the
typepfunction from the cl package. See Type Predicates. It therefore has the same issues as that package. Extensions include the ability to provide object names.
Defclass also supports class options, but does not currently use values of
:metaclass, and:default-initargs. make-instance- Make instance works as expected, however it just uses the EIEIO instance
creator automatically generated when a new class is created.
See Making New Objects.
defgeneric- Creates the desired symbol, and accepts all of the expected arguments
except
:around. defmethod- Calls defgeneric, and accepts most of the expected arguments. Only
the first argument to the created method may have a type specifier.
To type cast against a class, the class must exist before defmethod is
called. In addition, the
:aroundtag is not supported. call-next-method- Inside a method, calls the next available method up the inheritance tree
for the given object. This is different than that found in CLOS because
in EIEIO this function accepts replacement arguments. This permits
subclasses to modify arguments as they are passed up the tree. If no
arguments are given, the expected CLOS behavior is used.
setf- If the common-lisp subsystem is loaded, the setf parameters are also
loaded so the form
(setf (slot-value object slot) t)should work.
CLOS supports the describe command, but EIEIO only provides
eieio-describe-class, and eieio-describe-generic. These
functions are adviced into describe-variable, and
describe-function.
When creating a new class (see Building Classes) there are several new keywords supported by EIEIO.
In EIEIO tags are in lower case, not mixed case.
Next: GNU Free Documentation License, Previous: CLOS compatibility, Up: Top
20 Wish List
EIEIO is an incomplete implementation of CLOS. Finding ways to improve the compatibility would help make CLOS style programs run better in Emacs.
Some important compatibility features that would be good to add are:
:aroundmethod key.- Method dispatch for built-in types.
- Method dispatch for multiple argument typing.
- Improve integration with the cl package.
There are also improvements to be made to allow EIEIO to operate better in the Emacs environment.
- Allow subclassing of Emacs built-in types, such as faces, markers, and buffers.
- Allow method overloading of method-like functions in Emacs.
Next: Function Index, Previous: Wish List, Up: Top
Appendix A GNU Free Documentation License
Copyright © 2000, 2001, 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
http://fsf.org/
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
- PREAMBLE
The purpose of this License is to make a manual, textbook, or other functional and useful document free in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.
This License is a kind of “copyleft”, which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.
We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.
- APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The “Document”, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as “you”. You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.
A “Modified Version” of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.
A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.
The “Invariant Sections” are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.
The “Cover Texts” are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.
A “Transparent” copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not “Transparent” is called “Opaque”.
Examples of suitable formats for Transparent copies include plain ascii without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.
The “Title Page” means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, “Title Page” means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text.
The “publisher” means any person or entity that distributes copies of the Document to the public.
A section “Entitled XYZ” means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve the Title” of such a section when you modify the Document means that it remains a section “Entitled XYZ” according to this definition.
The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.
- VERBATIM COPYING
You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly display copies.
- COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.
If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.
It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.
- MODIFICATIONS
You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:
- Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.
- List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has fewer than five), unless they release you from this requirement.
- State on the Title page the name of the publisher of the Modified Version, as the publisher.
- Preserve all the copyright notices of the Document.
- Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
- Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.
- Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice.
- Include an unaltered copy of this License.
- Preserve the section Entitled “History”, Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled “History” in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.
- Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the “History” section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.
- For any section Entitled “Acknowledgements” or “Dedications”, Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.
- Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.
- Delete any section Entitled “Endorsements”. Such a section may not be included in the Modified Version.
- Do not retitle any existing section to be Entitled “Endorsements” or to conflict in title with any Invariant Section.
- Preserve any Warranty Disclaimers.
If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles.
You may add a section Entitled “Endorsements”, provided it contains nothing but endorsements of your Modified Version by various parties—for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.
You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.
- COMBINING DOCUMENTS
You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled “History” in the various original documents, forming one section Entitled “History”; likewise combine any sections Entitled “Acknowledgements”, and any sections Entitled “Dedications”. You must delete all sections Entitled “Endorsements.”
- COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.
- AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an “aggregate” if the copyright resulting from the compilation is not used to limit the legal rights of the compilation's users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document's Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.
- TRANSLATION
Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.
If a section in the Document is Entitled “Acknowledgements”, “Dedications”, or “History”, the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.
- TERMINATION
You may not copy, modify, sublicense, or distribute the Document except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and will automatically terminate your rights under this License.
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, receipt of a copy of some or all of the same material does not give you any rights to use it.
- FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License “or any later version” applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. If the Document specifies that a proxy can decide which future versions of this License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Document.
- RELICENSING
“Massive Multiauthor Collaboration Site” (or “MMC Site”) means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works. A public wiki that anybody can edit is an example of such a server. A “Massive Multiauthor Collaboration” (or “MMC”) contained in the site means any set of copyrightable works thus published on the MMC site.
“CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-profit corporation with a principal place of business in San Francisco, California, as well as future copyleft versions of that license published by that same organization.
“Incorporate” means to publish or republish a Document, in whole or in part, as part of another Document.
An MMC is “eligible for relicensing” if it is licensed under this License, and if all works that were first published under this License somewhere other than this MMC, and subsequently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus incorporated prior to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing.
ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:
Copyright (C) year your name.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the “with...Texts.” line with this:
with the Invariant Sections being list their titles, with
the Front-Cover Texts being list, and with the Back-Cover Texts
being list.
If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation.
If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.
Previous: GNU Free Documentation License, Up: Top
Function Index
call-next-method: Methodschild-of-class-p: Predicatesclass-children: Predicatesclass-children-fast: Predicatesclass-constructor: Predicatesclass-name: PredicatesCLASS-NAME-child-p: Building ClassesCLASS-NAME-p: Building Classesclass-of: Predicatesclass-option: Predicatesclass-p: Predicatesclass-parent: Predicatesclass-parents: Predicatesclass-parents-fast: Predicatesclass-slot-initarg: Introspectionclone: Basic Methodsdefclass: Building Classesdefgeneric: Genericsdefmethod: Methodsdelete-instance on eieio-instance-tracker: eieio-instance-trackereieio-build-class-alist: Association Listseieio-custom-widget-insert: Customizingeieio-customize-object: Customizingeieio-persistent-path-relative on eieio-persistent: eieio-persistenteieio-persistent-read: eieio-persistenteieio-persistent-save on eieio-persistent: eieio-persistenteieio-speedbar-child-description on eieio-speedbar: eieio-speedbareieio-speedbar-child-make-tag-lines on eieio-speedbar: eieio-speedbareieio-speedbar-derive-line-path on eieio-speedbar: eieio-speedbareieio-speedbar-description on eieio-speedbar: eieio-speedbareieio-speedbar-object-buttonname on eieio-speedbar: eieio-speedbareieio-speedbar-object-children on eieio-speedbar: eieio-speedbareieiodoc-class: Documentationfind-class: Predicatesgeneric-p: Predicatesinitialize-instance: Initializationinitialize-instance on eieio-instance-tracker: eieio-instance-trackerinvalid-slot-name: Signalsinvalid-slot-type: Signalskey: eieio-instance-trackermake-instance: Making New Objectsmake-map: eieio-speedbarnext-method-p: Methodsno-applicable-method: Signal Handlingno-method-definition: Signalsno-next-method: Signalsno-next-method: Signal Handlingobject-add-to-list: Accessing Slotsobject-assoc: Association Listsobject-assoc-list: Association Listsobject-class: Predicatesobject-class-fast: Predicatesobject-class-name: Predicatesobject-name: Predicatesobject-of-class-p: Predicatesobject-print: Basic Methodsobject-remove-from-list: Accessing Slotsobject-slots: Introspectionobject-write: Basic Methodsobject-write on eieio-persistent: eieio-persistentoref: Accessing Slotsoref-default: Accessing Slotsoset: Accessing Slotsoset-default: Accessing Slotsrecord: Making New Objectssame-class-fast-p: Predicatessame-class-p: Predicatesset-slot-value: Accessing Slotsshared-initialize: Initializationslot-boundp: Predicatesslot-exists-p: Predicatesslot-makeunbound: Accessing Slotsslot-missing: Signal Handlingslot-unbound: Signal Handlingslot-value: Accessing Slotsunbound-slot: Signalswith-slots: Accessing Slots
Table of Contents
- EIEIO
- 1 Quick Start
- 2 Introduction
- 3 Building Classes
- 4 Making New Objects
- 5 Accessing Slots
- 6 Writing Methods
- 7 Method Invocation
- 8 Predicates and Utilities
- 9 Association Lists
- 10 Customizing Objects
- 11 Introspection
- 12 Base Classes
- 13 Browsing class trees
- 14 Class Values
- 15 Documentation
- 16 Default Superclass
- 17 Signals
- 18 Naming Conventions
- 19 CLOS compatibility
- 20 Wish List
- Appendix A GNU Free Documentation License
- Function Index