Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

defstruct

defstruct( 
s_name 
s_slot1 [ s_slot2...] 
) 
=> t

Description

Creates a defstruct, a named structure that is a collection of one or more variables.

Defstructs can have slots of different types that are grouped together under a single name for handling purposes. They are the equivalent of structs in C. The defstruct form also creates an instantiation function, named make_<name> where name is the structure name supplied to defstruct. This constructor function takes keyword arguments: one for each slot in the structure. Once created, structures behave just like disembodied property lists.

Just like disembodied property lists, structures can have new slots added at any time. However these dynamic slots are less efficient than the statically declared slots, both in access time and space utilization.

Structures can contain instances of other structures; therefore one needs to be careful about structure sharing. If sharing is not desired, a special copy function can be used to generate a copy of the structure being inserted. The defstruct form also creates a function for the given defstruct called copy_<name>. This function takes one argument, an instance of the defstruct. It creates and returns a copy of the given instance. An example appears after the description of the other defstruct functions.

Arguments

s_name

A structure name.

s_slot1

Name of the first slot in structure s_name.

s_slot2

Name of the second slot in structure s_name.

Value Returned

t

Always returns t.

Examples

Returns the value associated with a slot of an instance.

defstruct(myStruct slot1 slot2 slot3)
struct = make_myStruct(?slot1 "one" ?slot2 "two" ?slot3 "three")
=>t
struct->slot1 
=> "one"

Modifies the value associated with a slot of an instance.

struct->slot1 = "new" 
=> "new"

Returns a list of the slot names associated with an instance.

struct->? 
=> (slot3 slot2 slot1)

Returns a property list (not a disembodied property list) containing the slot names and values associated with an instance.

struct->?? 
=> (slot3 "three" slot2 "two" slot1 "new")

Related Topics

defstruct

printstruct


Return to top
 ⠀
X