Professional Documents
Culture Documents
Reference
Product Version 6.1.6
November 2014
© 1990–2013 Cadence Design Systems, Inc. All rights reserved.
Printed in the United States of America.
Cadence Design Systems, Inc. (Cadence), 2655 Seely Ave., San Jose, CA 95134, USA.
Open SystemC, Open SystemC Initiative, OSCI, SystemC, and SystemC Initiative are trademarks or
registered trademarks of Open SystemC Initiative, Inc. in the United States and other countries and are
used with permission.
Trademarks: Trademarks and service marks of Cadence Design Systems, Inc. contained in this document
are attributed to Cadence with the appropriate symbol. For queries regarding Cadence’s trademarks,
contact the corporate legal department at the address shown above or call 800.862.4522. All other
trademarks are the property of their respective holders.
Restricted Permission: This publication is protected by copyright law and international treaties and
contains trade secrets and proprietary information owned by Cadence. Unauthorized reproduction or
distribution of this publication, or any portion of it, may result in civil and criminal penalties. Except as
specified in this permission statement, this publication may not be copied, reproduced, modified, published,
uploaded, posted, transmitted, or distributed in any way, without prior written permission from Cadence.
Unless otherwise agreed to by Cadence in writing, this statement grants Cadence customers permission to
print one (1) hard copy of this publication subject to the following conditions:
1. The publication may be used only in accordance with a written agreement between Cadence and its
customer.
2. The publication may not be modified in any way.
3. Any authorized copy of the publication or portion thereof must include all original copyright,
trademark, and other proprietary notices and this permission statement.
4. The information contained in this document cannot be used in the development of like products or
software, whether for internal or external use, and shall not be used for the benefit of any other party,
whether or not for consideration.
Disclaimer: Information in this publication is subject to change without notice and does not represent a
commitment on the part of Cadence. Except as may be explicitly set forth in such agreement, Cadence does
not make, and expressly disclaims, any representations or warranties as to the completeness, accuracy or
usefulness of the information contained in this document. Cadence does not warrant that use of such
information will not infringe any third party rights, nor does Cadence assume any liability for damages or
costs of any kind that may result from use of such information.
Restricted Rights: Use, duplication, or disclosure by the Government is subject to restrictions as set forth
in FAR52.227-14 and DFAR252.227-7013 et seq. or its successor
Cadence SKILL++ Object System Reference
Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Licensing in Cadence SKILL Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
About the SKILL Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Related Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Installation, Environment, and Infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Section Names and Meanings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Typographic and Syntax Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
SKILL Syntax Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Identifiers Used to Denote Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Additional Learning Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
How to Contact Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1
Classes and Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
allocateInstance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
changeClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
className . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
classOf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
classp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
defclass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
findClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
initializeInstance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
isClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
makeInstance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
printself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
setSlotValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
sharedInitialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
slotBoundp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
slotUnbound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
slotValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2
Generic Functions and Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
callAs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
callNextMethod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
defgeneric . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
defmethod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
getMethodSpecializers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
getGFbyClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
getApplicableMethods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
getMethodName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
getMethodRole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
getMethodSpec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
getGFproxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
nextMethodp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
removeMethod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
updateInstanceForDifferentClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
updateInstanceForRedefinedClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3
Generic Specializers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
ilArgMatchesSpecializer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
ilEquivalentSpecializers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
ilGenerateSpecializer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
ilSpecMoreSpecificp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4
Subclasses and Superclasses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
subclassesOf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
subclassp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
superclassesOf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5
Dependency Maintenance Protocol Functions . . . . . . . . . . . . . . . . 67
addDependent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
getDependents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
removeDependent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
updateDependent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Preface
This manual introduces the SKILL++ language to new users, leads users to understand
advanced topics and encourages sound SKILL programming methods. It is aimed at the
following users:
■ CAD developers who have experience programming in SKILL, both Cadence internal
users and Cadence® customers
■ Programmers beginning to program in SKILL++
■ CAD integrators
For information on licensing in the Cadence SKILL Language, see Virtuoso Software
Licensing and Configuration Guide.
SKILL is ideal for rapid prototyping. You can incrementally validate the steps of your algorithm
before incorporating them in a larger program.
Storage management errors are persistently the most common reason cited for schedule
delays in traditional software development. SKILL’s automatic storage management relieves
your program of the burden of explicit storage management. You gain control of your software
development schedule.
SKILL also controls notoriously error-prone system programming tasks like list management
and complex exception handling, allowing you to focus on the relevant details of your
algorithm or user interface design. Your programs will be more maintainable because they will
be more concise.
The Cadence environment allows SKILL program development such as user interface
customization. The SKILL Development Environment contains powerful tracing, debugging,
and profiling tools for more ambitious projects.
SKILL leverages your investment in Cadence technology because you can combine existing
functionality and add new capabilities.
SKILL allows you to access and control all the components of your tool environment: the User
Interface Management System, the Design Database, and the commands of any integrated
design tool. You can even loosely couple proprietary design tools as separate processes with
SKILL’s interprocess communication facilities.
Related Documents
The following documents provide more information about SKILL and other topics discussed
in this guide.
Description A brief phrase identifying the purpose of the function and the text
description of the operation performed by the function.
References Other functions that are relevant to the operation of this function:
ones with partial or similar functionality or which could be called
by or could call this function. Sections in this manual which
explain how to use this function.
literal (LITERAL)
Nonitalic (UPPERCASE) words indicate keywords that you must
enter literally. These keywords represent command (function,
routine) or option names.
argument (z_argument)
Words in italics indicate text that you must replace with an
appropriate argument. The prefix (in this case, z_) indicates the
data type that the argument can accept. Names are case
sensitive. Do not type the data type or underscore before your
arguments.
{ } Braces are used with vertical bars and enclose a list of choices
from which you must choose one.
... Three dots (...) indicate that you can repeat the previous
argument. If you use them with brackets, you can specify zero or
more arguments. If they are used without brackets, you must
specify at least one argument, but you can specify more.
,... A comma and three dots together indicate that if you specify
more than one argument, you must separate those arguments by
commas.
=> A right arrow points to the return values of the function. Variable
values returned by the software are shown in italics. Returned
literals, such as t and nil, are in plain text. The right arrow is
also used in code examples in SKILL manuals.
Example 1
list( g_arg1 [g_arg2] ...) => l_result
list Plain type indicates words that you must enter literally.
g_arg1 Words in italics indicate arguments for which you must substitute
a name or a value.
... Three dots indicate that the preceding item can appear any
number of times.
=> A right arrow points to the description of the return value of the
function. Also used in code examples in SKILL manuals.
l_result All SKILL functions compute a data value known as the return
value of the function.
Example 2
needNCells( s_cellType | st_userType x_cellCount) => t / nil
Data types are identified by a single letter followed by an underscore; for example, t is the
data type in t_viewNames. Data types and the underscore are used as identifiers only; they
should not be typed.
For information on SKILL language, see Cadence SKILL Language User Guide.
For further information on these and other related Virtuoso Layout Suite training courses
available in your region, visit the Cadence Training portal. You can also write to
training_enroll@cadence.com.
Note: The links in this section open in a new browser. The course links initially display the
requested training information for North America, but if required, you can navigate to the
courses available in other regions
You can also use Cadence Online Support to find out the latest information on Virtuoso
Parasitic Aware Design.
1
Classes and Instances
allocateInstance
allocateInstance(
u_class
)
=> g_instance
Description
Creates and returns an empty instance of the specified class. All slots of the new instance
are unbound.
Arguments
u_class The specified class for which a new instance has to be created.
Value Returned
Example
defclass(A () ((slot1 @initform 1) (slot2 @initform 2)))
i = allocateInstance(findClass('A))
i->??
=> (slot1 \*slotUnbound\* slot2 \*slotUnbound\*)
i = allocateInstance('A)
i->??
=> (slot1 \*slotUnbound\* slot2 \*slotUnbound\*)
changeClass
changeClass(
g_inst
g_className
[g_initArgs]
)
=> g_updatedInst
Description
Changes the class of the given instance (g_inst) to the specified class (g_className).
Arguments
Value Returned
Example
(defclass A () ())
(defclass B (A) ((slot @initarg s)))
x = (makeInstance 'A)
(changeClass x 'B ?s 1)
(classOf x)
=> class:B
className
className(
us_class
)
=> s_className
Description
Arguments
Value Returned
Example
className( classOf( 5 )) => fixnum
defclass( GeometricObject
() ;;; standardObject is the subclass by default
() ;;; no slots
) ; defclass
className(findClass( 'GeometricObject))
=> GeometricObject
geom = makeInstance( 'GeometricObject )
className( classOf( geom))
=> GeometricObject
Reference
classOf, findClass
classOf
classOf(
g_object
)
=> u_classObject
Description
Arguments
Value Returned
Examples
classOf( 5 )
=> class:fixnum
className( classOf( 5 ))
=> fixnum
Reference
className, findClass
classp
classp(
g_object
su_class
)
=> t | nil
Description
Checks if the given object is an instance of the given class or is an instance of one of its
subclasses.
Arguments
Value Returned
Example
classp( 5 classOf( 5 )) => t
classp( 5 'fixnum ) => t
classp( 5 'string ) => nil
classp( 5 'noClass )
*Error* classp: second argument must be a class - nil
Reference
classOf, className
defclass
defclass(
s_className
( [ s_superClassName ] )
( [ ( 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 and slot specifications.
This is a macro form.
If the 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.
Note: 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
Value Returned
t Always returns t.
Example 1
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 )
findClass
findClass(
s_className
)
=> u_classObject | nil
Description
Returns the class object associated with a symbol. The symbol is the symbolic name of the
class object.
Arguments
Value Returned
Example
findClass( 'Point ) => funobj:0x1c9968
findClass( 'fixnum ) => funobj:0x1840d8
findClass( 'standardObject => funobj:0x184028
findClass( 'fuzzyNumber ) => nil
Reference
defclass, className
initializeInstance
initializeInstance(
g_instance
[ u_?initArg1 value1 ]
[ u_?initArg2 value2 ] ...
)
=> t
Description
Arguments
Value Returned
Example
defclass( A () ())
=>t
defmethod( initializeInstance ((obj A) @key (a 3) @rest args))
(printf "initializeInstance : A : was called with args - obj == '%L'
a == '%L' rest == '%L'\n" obj a args)
(callNextMethod)
=>t
makeInstance( 'A ?a 7)
initializeInstance : A : was called with args - obj == 'stdobj@0x83bf048' a
== '7' rest == 'nil'
=>stdobj@0x83bf048
makeInstance( 'A)
initializeInstance : A : was called with args - obj == 'stdobj@0x83bf054' a
== '3' rest == 'nil'
=>stdobj@0x83bf054
isClass
isClass(
g_object
)
=> t | nil
Description:
Arguments
Value Returned
Example
isClass( classOf( 5 ) ) => t
isClass( findClass( 'Point ) ) => t
isClass( 'noClass ) => nil
Reference
classOf, findClass
makeInstance
makeInstance(
us_class
[ u_?initArg1 value1 ]
[ u_?initArg2 value2 ] ...
)
=> g_instance
Description
Arguments
us_class Class object or a symbol denoting a class object. The class must
be either standardObject or a subclass of standardObject.
u_?initArg1 value1 The symbol u_initArg1 is specified in one of the slot specifiers
u_?initArg2 in the defclass declaration of either us_class or a
value2 superclass of us_class. value1 is the initial value for that
slot. Similarly for the pair u_initArg2 value2 and so forth.
Value Returned
Example
defclass( Circle ( GeometricObject )
(( center @initarg c ) ( radius @initarg r )) ) => t
P = makeInstance( 'Point ?name "P" ?x 3 ?y 4 )
=> stdobj:0x1d003c
C = makeInstance( 'Circle ?c P ?r 5.0 ) => stdobj:0x1d0048
makeInstance( 'fixnum )
*Error* unknown: non-instantiable class - fixnum
Reference
defclass
printself
printself(
g_object
)
=> g_result
Description
Arguments
Value Returned
Example
defmethod( printself ((obj myClass))
sprintf(nil "#{instance of myClass:%L}" obj) ; returns a string
)
i = makeInstance('myClass)
=> #{instance of myClass:stdobj@0x83ba018}
; prints all instances of myClass
setSlotValue
setSlotValue(
g_standardObject
s_slotName
g_value
)
=> g_value
Description
An error is signaled if there is no such slot for the g_standardObject. This function
bypasses any @writer generic function for the slot that you specified in the defclass
declaration for the g_standardObject’s class.
Arguments
Value Returned
Example
defclass( GeometricObject ()
(
( x @initarg x )
( y @initarg y )
)
) => t
geom = makeInstance( 'GeometricObject ?x 0 )
=> stdobj:0x34b018
slotValue( geom 'y ) => \*slotUnbound\*
setSlotValue( geom 'y 2 ) => 2
slotValue( geom 'y ) => 2
sharedInitialize
sharedInitialize(
g_object
g_slotList
@rest l_initargs
)
=> g_object | error
Description
This is a generic function, which is called when an instance is created, re-initialized, updated
to conform to a redefined class, or updated to conform to a different class. It is called from the
initializeInstance, updateInstanceForRedefinedClass, and
updateInstanceForDifferentClass functions to initialize slots of the instance
g_object using the corresponding initforms.
Arguments
Value Returned
Example
defclass( A () ((a @initform 1)))
=>t
defmethod( sharedInitialize ((obj A) slots @key k @rest args)
(printf "sharedInitialize A: obj->?? == '%L' k == '%L' args == '%L'\n" obj->?? k
args)
(callNextMethod)
)
=>t
defclass( B () ((b @initform 2)))
=>t
x = makeInstance( 'A ?k 9)
sharedInitialize A: obj->?? == '(a \*slotUnbound\*)' k == '9' args == 'nil'
=>stdobj@0x83bf018
defclass( A () ((a @initform 1)
(c @initform 3)))
*WARNING* (defclass): redefinition of class A updating stdobj@0x83bf018
sharedInitialize A: obj->?? == '(a 1 c \*slotUnbound\*)' k == 'nil' args == 'nil'
=>t
changeClass( x 'B ?k 7)
updating stdobj@0x83bf018
stdobj@0x83bf018
x->??
(b 2)
changeClass( x 'A ?k 7)
updating stdobj@0x83bf018
sharedInitialize A: obj->?? == '(a \*slotUnbound\* c \*slotUnbound\*)' k == '7'
args == 'nil'
stdobj@0x83bf018
x->??
(a 1 c 3)
slotBoundp
slotBoundp(
obj
t_slotName
)
=> t/nil
Description
Arguments
Value Returned
Example
myObject => slotX = 20
slotBoundp(myObject "slotX") => t
slotUnbound
slotUnbound(
u_class
g_object
s_slotName
)
=> g_result
Description
This function is called when the slotValue function attempts to reference an unbound slot.
It signals that the value of the slot s_slotName of g_object has not been set yet. In this
case, slotValue returns the result of the method.
Arguments
Value Returned
Example
defclass( A () ((a)))
=>t
x = (makeInstance 'A)
=>stdobj@0x83bf018
defmethod( slotUnbound (class (obj A) slotName) (printf "slotUnbound : slot '%L'is
unbound\n" slotName) (setSlotValue obj slotName 6)
)
=>t
x->a
=>slotUnbound : slot 'a' is unbound
=>6
x->a
=>6
slotValue
slotValue(
g_standardObject
s_slotName
)
=> g_value
Description
Returns the value contained in the slot slotName of the given standardObject.
If there is no slot with the given name an error is signalled. This function bypasses any
@reader generic function for the slot that you specified in the defclass declaration for the
g_standardObject’s class.
Arguments
Value Returned
Example
defclass( GeometricObject ()
(
( x @initarg x )
( y @initarg y )
)
)
=> t
defclass( Point
( GeometricObject)
(
( name @initarg name )
)
) => t
2
Generic Functions and Methods
callAs
callAs(
us_class
s_genericFunction
g_arg1
[ g_arg2 ... ]
)
=> g_value
Description
Calls a method specialized for some super class of the class of a given object directly,
bypassing the usual method inheritance and overriding of a generic function.
It is an error if the given arguments do not satisfy the condition (classp g_obj
us_class).
Arguments
Value Returned
Example
defclass( GeometricObj () ())
=> t
defclass( Point (GeometricObj ) () )
=> t
defgeneric( whoami (obj) println("default"))
=> t
defmethod( whoami (( obj Point )) println("Point"))
=> t
defmethod( whoami (( obj GeometricObj))
println( "GeometricObj"))
=> t
p = makeInstance( 'Point )
=> stdobj:0x325018
whoami(p) ;prints "Point"
=> nil
callAs( 'GeometricObj 'whoami p ) ;prints "GeometricObj"
=> nil
Reference
nextMethodp, callNextMethod
callNextMethod
callNextMethod(
[ g_arg ... ]
)
=> g_value
Description
Calls the next applicable method for a generic function from within the current method.
Returns the value returned by the method it calls.
This function can only be (meaningfully) used in a method body to call the next more general
method in the same generic function.
You can call callNextMethod with no arguments, in which case all the arguments passed
to the calling method will be passed to the next method. If arguments are given, they will be
passed to the next method instead.
Arguments
Value Returned
Example
Reference
nextMethodp, callAs
defgeneric
defgeneric(
s_functionName
( s_arg1
[ s_arg2 ... ]
)
[ g_exp ... ]
)
=> t
Description
Defines a generic function with an optional default method. This is a macro form. Be sure to
leave a space after the function name. See the Cadence SKILL Language User Guide for
a discussion of generic functions.
Arguments
s_functionName Name of the generic function. Be sure to leave a space after the
function name.
s_arg1 Any valid argument specification for SKILL functions, including
@key, @rest, and so forth.
g_exp The expressions that compose the default method. The default
method is specialized on the class t for the first argument.
Because all SKILL objects belong to class t, this represents the
most general method of the generic function and is applicable to
any argument.
Value Returned
Example
ILS-<2> defgeneric( whatis ( object )
printf(
"%L is an instance of %s\n"
object className( classOf( object))
)
) ; defgeneric
ILS-<2> whatis( 5 )
5 is an instance of fixnum
t
ILS-<2> whatis( "abc" )
"abc" is an instance of string
t
Reference
defmethod
defmethod
defmethod(
s_name
(
( s_arg1
s_class
)
s_arg2 ...
)
g_exp1 ...
)
=> t
Description
Defines a method for a given generic function. This is a macro form. Be sure to leave a space
after s_name.
Arguments
Value Returned
t Always returns t.
Example
defmethod( whatis (( p Point ))
sprintf( nil "%s %s @ %n:%n"
className( classOf( p ))
p->name
p->x
p->y
)
) ; defmethod
=> t
Reference
defgeneric, procedure, defun
getMethodSpecializers
getMethodSpecializers(
s_genericFunction
)
=> l_classNames | nil
Description
Returns the specializers of all methods currently associated with the given generic function,
in a list of class names. The first element in the list is t if there is a default method.
Arguments
Value Returned
Example
defmethod( met1 ((obj number)) println(obj))
=> t
getMethodSpecializers(’met1)
=>(number)
defclass( XGeometricObj () () )
=> t
defgeneric( whoami (obj) printf("Generic Object\n"))
=> t
defmethod( whoami (( obj XGeometricObj)) printf( "XGeometricObj, which is also
a\n"))
=> t
getMethodSpecializers(’whoami)
=> (t XGeometricObj)
getMethodSpecializers(’car)
=> *Error* getMethodSpecializers: first argument must be a generic function - car
nil
getMethodSpecializers(2)
=> *Error* getMethodSpecializers: argument #1 should be a symbol (type template =
"s") - 2
getGFbyClass
getGFbyClass(
s_className
[g_nonExistent]
)
=> l_methods
Description
Arguments
s_className Name of the class for which you want view the list of specializing
functions.
Value Returned
Example
getGFbyClass('systemObject)
=> (printObject)
getApplicableMethods
getApplicableMethods(
s_gfName
l_args
)
=>l_funObjects
Description
Returns a list of applicable methods (funObjects) for the specified generic function for a
given set of arguments. The returned list contains methods in the calling order.
Arguments
Values Returned
Example
getApplicableMethods('testMethod list("test" 42))
=> (funobj@0x83b76d8 funobj@0x83b76f0 funobj@0x83b76a8 funobj@0x83b7678
funobj@0x83b7690 funobj@0x83b7630 funobj@0x83b7600 funobj@0x83b76c0 )
getMethodName
getMethodName(
U_funObject
)
=>s_name
Description
Arguments
U_funObject Specifies the name of the function object for which you want to
retireve the method name
Values Returned
s_name Returns the method name for the specified generic function
object
Example
getMethodName(funobj@0x0182456)
=> testMethod
getMethodRole
getMethodRole(
U_funObject
)
=>s_role / nil
Description
Returns the method role for the given function object. U_funObject should be a valid generic
function object.
Arguments
U_funObject Specifies the name of the function object for which you want to
retireve the method role. This should be a valid generic function
object.
Values Returned
Example
getMethodRole(funobj@0x0182456)
=> @before
getMethodSpec
getMethodSpec(
U_funObject
)
=>l_spec
Description
Returns the list of specializer for the given funobject. U_funObject should be a valid generic
method object.
Arguments
U_funObject Specifies the name of the function object for which you want to
retrieve the list of specializers. This should be a valid generic
method object.
Values Returned
Example
getMethodSpec(funobj@0x0182456)
=> (string number)
getGFproxy
getGFproxy(
s_gfName
)
=> U_classObj / nil
Description
Arguments
Value Returned
Example
getGFproxy('niTest); niTest is the name of the generic function
=> stdobj@0x83c0018
classOf(getGFproxy('niTest))
=> class:niGF
classOf(getGFproxy('printself)) ;; class of standard generic function (printself)
=> class:ilGenericFunction ;; default
getGFproxy('abc)
=> nil ;; non-existing generic function
nextMethodp
nextMethodp(
)
=> t | nil
Description
Checks if there is a next applicable method for the current method’s generic function. The
current method is the method that is calling nextMethodp.
nextMethodp is a predicate function which returns t if there is a next applicable method for
the current method’s generic function. This next method is specialized on a superclass of the
class on which the current method is specialized.
Prerequisites
This function should only be used within the body of a method to determine whether a next
method exists.
Caution
The return value and the effect of this function are unspecified if called
outside of a method body.
Arguments
None.
Value Returned
Example
defclass( GeometricObj () ())
=> t
defclass( Point ( GeometricObj ) () )
=> t
defmethod( whoami (( obj Point ))
if( nextMethodp()
Prints Point.
defmethod( whoami (( obj GeometricObj))
println( "GeometricObj"))
=> t
whoami( p)
=> nil
Reference
defmethod, callNextMethod
removeMethod
removeMethod(
s_genFunction
g_className
[g_method]
)
=> t/nil
Description
Arguments
s_genFunction Name of the generic function from which the method needs to be
removed.
g_className Name of the class or list of classes to which the generic function
belongs.
g_method Specifies the method qualifier. It can have one of the following
values: '@before, '@after, and '@around. If this value is not
provided or is specified as nil, then the primary method is
removed.
Value Returned
Example
removeMethod('my_function 'my_class '@before)
updateInstanceForDifferentClass
updateInstanceForDifferentClass(
g_previousObj
g_currentObj
@rest initargs
)
=> t
Description
A generic function, which is called from changeClass to update the specified instance
(g_currentObj).
Arguments
Value Returned
t Always returns t
updateInstanceForRedefinedClass
updateInstanceForRedefinedClass(
obj
l_addedSlots
l_deletedSlots
l_dplList
)
=> t
Description
It is a generic function, which is called to update all instances of a class, when a class
redefinition occurs.
When a class is redefined and an instance is being updated, a property-list is created that
captures the slot names and values of all the discarded slots with values in the original
instance. The structure of the instance is transformed so that it conforms to the current class
definition.
Arguments
Value Returned
t Always returns t
Example
Define a method for the class myClass (to be applied to all instances of myClass if it is
redefined):
(defmethod updateInstanceForRedefinedClass ((obj myClass) added deleted
dplList @rest initargs)
;;callNextMethod for obj and pass ?arg "myArg" value for slot arg
(apply callNextMethod obj added deleted dplList ?arg "myArg" initargs)
3
Generic Specializers
ilArgMatchesSpecializer
ilArgMatchesSpecializer(
U_genericfuncObj
s_specClass
s_specArg)
=> t/nil
Description
Arguments
Value Returned
Example
(defmethod ilArgMatchesSpecializer (gf (theClass mySpec) arg)
(eq arg->type 'polygon))
ilEquivalentSpecializers
ilEquivalentSpecializers(
U_genericfuncObj
s_spec1
s_spec2)
=> t/nil
Description
Defines a method to check if two specializers are equal (required during method redefinition).
Arguments
Value Returned
Example
(defmethod ilEquivalentSpecializers(gf spec1 spec2)
classOf(spec1) == classOf(spec2))
ilGenerateSpecializer
ilGenerateSpecializer(
U_genericfuncObj
s_specClass
s_specArg)
=> g_expression
Description
Returns a SKILL expression that makes an instance of the given specializer class and
optionally set the slots. In the generated SKILL expression, s_specArg can be used to
initialize the slots.
Arguments
Value Returned
Example
; create an instance without any slot
(defmethod ilGenerateSpecializer (gf (specName t) specArgs)
`(makeInstance ',specName)
ilSpecMoreSpecificp
ilSpecMoreSpecificp(
U_genericfuncObj
s_spec1
s_spec2
s_specArg)
=> t / nil
Description
Checks if spec1is more specific than spec2. You need to define all required
ilSpecMoreSpecificp methods for all existing custom specializers (so that the system
can find a method to compare any pair of custom specializers).
Arguments
Value Returned
Example
(defmethod ilSpecMoreSpecificp (gf (spec1 classSpec1) (spec2 classSpec2)
args)spec1->value > spec2->value)
4
Subclasses and Superclasses
subclassesOf
subclassesOf(
u_classObject
)
=> l_subClasses
Description
Returns the ordered list of all (immediate) subclasses of u_classObject. Each element
in the list is a class object.
The list is sorted so that each element of the list is a subclass of the remaining elements.
Arguments
Value Returned
l_subClasses The list of subclasses. If the argument is not a class object, then
l_subClasses is nil.
Example
L = superclassesOf( findClass( 'fixnum ))
subclassesOf( findClass( ’primitiveObject ) )
=> (class:list class:port class:funobj class:array class:string
class:symbol class:number
)
subclassp
subclassp(
u_classObject1
u_classObject2
)
=> t | nil
Description
Arguments
Value Returned
Example
subclassp( findClass( 'Point ) findClass( 'standardObject )) => t
subclassp(
findClass( 'fixnum )
findClass( 'primitiveObject ))
=> t
subclassp(
findClass( 'standardObject )
findClass( 'primitiveObject )
)
=> nil
Reference
superclassesOf
superclassesOf
superclassesOf(
u_classObject
)
=> l_superClasses
Description
Returns the ordered list of all super classes of u_classObject. Each element in the list is
a class object.
The list is sorted so that each element of the list is a subclass of the remaining elements.
Note: If a class is inherited from multiple classes, superclassesOf() traverses the entire
inheritance tree and returns the linearized class list.
Arguments
Value Returned
l_superClasses The list of super classes. If the argument is not a class object,
then l_superClasses is nil.
Example
defclass(basicA () ())
defclass(basicB () ())
defclass(derived1 (basicA) ())
defclass(derived2 (basicA basicB) ())
superclassesOf(findClass('derived1))
=> (class:derived1 class:basicA class:standardObject class:t)
superclassesOf(findClass('derived2))
=> (class:derived2 class:basicA class:basicB class:standardObject class:t)
5
Dependency Maintenance Protocol
Functions
The dependency maintenance protocol provides a way to register an object that is notified
whenever a class or generic function on which it is set is modified. The registered object is
called a dependent of the class or generic function metaobject. SKILL uses the
addDependent and removeDependent methods to maintain the dependents of a class or
a generic function metaobject. The dependents can be accessed using the getDependents
method. The dependents are notified about a modified class or generic function by calling the
updateDependent method.
addDependent
addDependent(
g_object
g_dependent
)
=> t | nil
Description
Registers a dependent object for given object. SKILL checks if g_dependent already
exists as a dependent of g_object (using the eqv operator), then g_dependent is not
registered again and nil is returned.
Arguments
g_dependent Specifies the dependent object that you want to set on the given
object
Value Returned
nil Returns nil if the dependent object is already registered for the
given object
Example 1
addDependent( findClass('class) 'dep1)
This example registers the dependent object, dep1, for an object of class, class.
getDependents
getDependents(
g_object
)
=> l_dependents
Description
Returns a list of dependents registered for the given SKILL object, which could be a class or
a generic function
Arguments
Value Returned
Example 1
getDependents( findClass('class))
=> (dep1 dep2)
removeDependent
removeDependent(
g_object
g_dependent
)
=> t | nil
Description
Arguments
Value Returned
Example 1
removeDependent( findClass('class) 'dep1)
This example removes the dependent object, dep1, from the object of class, class.
updateDependent
updateDependent(
u_class
g_dependent
s_notifType
u_classObj
)
=> t
Description
Updates the dependents of a SKILL object, which could be a class or a generic function,
when the SKILL object is modified. The SKILL engine calls this method for each
g_dependent at different times. For example, if g_dependent is a method, the SKILL
engine calls updateDependent at the time of adding or removing the method; whereas, for
dependent classes the SKILL engine calls the updateDependent method at the end of
class creation.
Note: Your applications can implement methods on this generic function.
Arguments
s_notifType Specifies the type of update that has occurred using the following
qualifiers add_method, remove_method, add_class,
redef_class, add_generic, and redef_generic.
u_classObj Specifies the class object when a new class is defined. This
argument is nil when a class is redefined.
Value Returned
Example 1
defmethod( ilUpdateDependent((proxy class) obj dep type)
printf("updateDependent called for CLASS -- %L" classOf(proxy))
printf(" obj : %L type : %L\n" obj type)
printf("Dependents : %L\n" get(className(proxy) '\*dependents\*))
printf("Dependent : %L\n" dep)
t
)