Product Documentation
Cadence SKILL++ Object System Reference
Product Version IC23.1, June 2023

defclass

defclass( 
s_className
     ( [ s_superClassName1 ]...[ s_superClassNameN ]
( [ ( s_slotName
[ @initarg s_argName ]
[ @reader s_readerFun ]
[ @writer s_writerFun ]
[ @initform g_exp ]
)
]
)
)
=> t

Description

Creates a class object with class name and optional super class name (or names) and slot specifications. This is a macro form.

If a super class is not given, the default super class is the standardObject class.

Each slot specifier itself is a list composed of slot options. The only required slot option is the slot name.

If you define a class with two slots that have the same name, as shown in the example given below, SKILL creates the class but also issues a warning.
defclass(A () ((slotA) (slotB) (slotA @initform 42)))

Arguments

s_className

Name of new class.

s_superClassName1 ... s_superClassNameN

Names of one or more super classes. Default is standardObject.

s_slotName

Name of the slot.

@initarg s_argName

Declares an initialization argument named s_argName. Calls to makeInstance can use s_argName as keyword argument to pass an initialization value.

@reader s_readerFun

Specifies that a method be defined on the generic function named s_readerFun to read the value of the given slot.

@writer s_writerFun

Specifies that a method be defined on the generic function named s_writerFun to change the value of the given slot.

@initform g_exp

The expression is evaluated every time an instance is created. The @initform slot option is used to provide an expression to be used as a default initial value for the slot. The form is evaluated in the class definition environment.

Value Returned

t

Always returns t.

Examples

defclass( Point
( GeometricObject )
(
( name @initarg name )
( x @initarg x ) ;;; x-coordinate
( y @initarg y ) ;;; y-coordinate
)
) ; defclass => t
P = makeInstance( 'Point ?name "P" ?x 3 ?y 4 )
defclass(A (B C) ((slot1) (slot2) (slot2 @initform 42)))

Related Topics

Classes and Instances

Defining a Class (defclass)


Return to top
 ⠀
X