Contents
Before You Start
About This Manual
Companion Reference Manual
Audience
About the SKILL Language
Quick Look at All the Chapters
What’s New
SKILL Development Help
Quick Reference Tool - Finder
Copying and Pasting Code Examples
Other Sources of Information
Product Installation
Other SKILL Development Documentation
Related SKILL API Documentation
Document Conventions
Syntax Conventions
Data Types
Getting Started
Overview
Relationship to Lisp
A Quick Look at the Cadence SKILL Language
Terms and Definitions
Invoking a SKILL Function
What Is a Return Value?
Simplest SKILL Data
How Do You Call a Function?
Operators Are SKILL Functions
Using Variables
Alternative Ways to Enter a Function
Solving Some Common Problems
What Is a SKILL List?
Building Lists
Accessing Lists
Modifying Lists
File Input/Output
Displaying Data
Writing Data to a File
Reading Data from a File
Flow of Control
Relational Operators
Logical Operators
The if Function
The when and unless Functions
The case Function
The for Function
The foreach Function
Developing a SKILL Function
Grouping SKILL Statements
Declaring a SKILL Function
Defining Function Parameters
Selecting Prefixes for Your Functions
Maintaining SKILL Source Code
Loading Your SKILL Source Code
Redefining a SKILL Function
Language Characteristics
Overview
Naming Conventions
Names of Functions
Cadence-Private Functions
Names of Variables
Function Calls
SKILL Syntax
Special Characters
Comments
White Space
Parentheses
Super Right Bracket
Backquote, Comma, and Comma-At
Line Continuation
Length of Input Lists
Data Characteristics
Data Types
Numbers
Strings
Atoms
Escape Sequences
Symbols
Characters
Creating Functions in SKILL
Basic Concepts
Terms and Definitions
Kinds of Functions
Syntax Functions for Defining Functions
procedure
lambda
nprocedure
defmacro
mprocedures
Summary of Syntax Functions
Defining Parameters
@rest Option
@optional Option
@key Option
Combining Arguments
Type Checking
Specifying the Argument Type Template
Local Variables
Defining Local Variables (let, prog)
Initializing Local Variables to Non-nil Values
Global Variables
Testing Global Variables
Avoiding Name Clashes
Naming Scheme
Reducing the Number of Global Variables
Redefining Existing Functions
Physical Limits for Functions
Data Structures
Access Operators
Symbols
Creating Symbols
The Print Name of a Symbol
The Value of a Symbol
The Function Binding of a Symbol
The Property List of a Symbol
Important Symbol Property List Considerations
Disembodied Property Lists
Important Considerations
Additional Property List Functions
Strings
Concatenating Strings
Comparing Strings
Getting Character Information in Strings
Indexing with Character Pointers
Creating Substrings
Converting Case
Pattern Matching of Regular Expressions
Pattern Matching Functions
Defstructs
Behavior Is Similar to Disembodied Property Lists
Additional Defstruct Functions
Accessing Named Slots in SKILL Structures
Extended defstruct Example
Arrays
Allocating an Array of a Given Size
Accessing Arrays
Association Tables
Initializing Tables
Manipulating Table Data
Association Table Functions
Traversing Association Tables
Implementing Sparse Arrays
Association Lists
User-Defined Types
Arithmetic and Logical Expressions
Evaluating Expressions
Constants
Variables
Function Calls
Creating Arithmetic and Logical Expressions
Role of Parentheses
Quoting to Prevent Evaluation
Arithmetic and Logical Operators
Predefined Arithmetic Functions
Bitwise Logical Operators
Bit Field Operators
Mixed-Mode Arithmetic
Function Overloading
Integer-Only Arithmetic
True (non-nil) and False (nil) Conditions
Controlling the Order of Evaluation
Testing Arithmetic Conditions
Differences Between SKILL and C Syntax
SKILL Predicates
Using Predicates Efficiently
Type Predicates
Control Structures
Control Functions
Conditional Functions
Iteration Functions
Selection Functions
Declaring Local Variables with prog
The prog Function
The return Function
Grouping Functions
Using prog, return, and let
Using the progn Function
Using the prog1 and prog2 Functions
I/O and File Handling
File System Interface
Files
Directories
Directory Paths
The SKILL Path
Working with the SKILL Path
Working with the Installation Path
Checking File Status
Working with Directories
Ports
Predefined Ports
Opening and Closing Ports
Output
Unformatted Output
Formatted Output
Pretty Printing
Input
Reading and Evaluating SKILL Formats
Reading but Not Evaluating SKILL Formats
Reading Application-Specific Formats
Reading Application-Specific Formats from Strings
System-Related Functions
Executing UNIX Commands
System Environment
Advanced List Operations
Conceptual Background
How Lists Are Stored in Virtual Memory
Destructive versus Non-Destructive Operations
Summary of List Operations
Altering List Cells
The rplaca Function
The rplacd Function
Accessing Lists
Selecting an Indexed Element from a List (nthelem)
Applying cdr to a List a Given Number of Times (nthcdr)
Getting the Last List Cell in a List (last)
Building Lists Efficiently
Adding Elements to the Front of a List (cons, xcons)
Building a List with a Given Element (ncons)
Adding Elements to the End of a List (tconc)
Appending Lists
Reorganizing a List
Reversing a List
Sorting Lists
Searching Lists
The member Function
The memq Function
The exists Function
Copying Lists
The copy Function
Copying a List Hierarchically
Filtering Lists
The setof Function
Removing Elements from a List
Non-Destructive Operations
Destructive Operations
Substituting Elements
Transforming Elements of a Filtered List
Validating Lists
The forall Function
The exists Function
Using Mapping Functions to Traverse Lists
Using lambda with the map* Functions
Using the map* Functions with the foreach Function
The mapc Function
The map Function
The mapcar Function
The maplist Function
The mapcan Function
Summarizing the List Traversal Operations
List Traversal Case Studies
Handling a List of Strings
Making Every List Element into a Sublist
Using mapcan for List Flattening
Flattening a List with Many Levels
Manipulating an Association List
Using the exists Function to Avoid Explicit List Traversal
Commenting List Traversal Code
Advanced Topics
Cadence SKILL Language Architecture and Implementation
Evaluation
Evaluating an Expression (eval)
Getting the Value of a Symbol (symeval)
Applying a Function to an Argument List (apply)
Function Objects
Retrieving the Function Object for a Symbol (getd)
Assigning a New Function Binding (putd)
Declaring a Function Object (lambda)
Evaluating a Function Object
Efficiently Storing Programs as Data
Macros
Benefits of Macros
Macro Expansion
Redefining Macros
defmacro
mprocedure
Using the Backquote (') Operator with defmacro
Using an @rest Argument with defmacro
Using @key Arguments with defmacro
Variables
Lexical Scoping
Dynamic Scoping
Dynamic Globals
Error Handling
The errset Function
Using err and errset Together
The error Function
The warn Function
The getWarn Function
Top Levels
Memory Management (Garbage Collection)
How to Work with Garbage Collection
Printing Summary Statistics
Allocating Space Manually
Exiting SKILL
Delivering Products
Contexts
What Are Contexts?
When to Use Contexts
Creating Contexts
Creating Utility Functions
Building the Contexts
Initializing Contexts
Loading Contexts
Customizing External Contexts
Potential Problems
Context Building Functions
Autoloading Your Functions
Encrypting and Compressing Files
Protecting Functions and Variables
Explicitly Protecting Functions
Protecting Variables
Global Function Protection
Writing Style
Introduction
Code Layout
Comments and Documentation
Function Calls and Brackets
Commas
Using Globals
Misusing Globals
Common Coding Style Mistakes
Inefficient Use of Conditionals
Misusing prog and Conditionals
Red Flags
Optimizing SKILL
Introduction
Focus Your Efforts
Use Profiling Tools
Optimizing Techniques
Macros
Caching
Mapping and Qualifying
Write Protection
Minimizing Memory
General Tips
Element Comparison
List Accessing
List Building
List Searching
List Sorting
Element Removal and Replacing
Alternatives to Lists
Miscellaneous Comparative Timings
Element Comparison
List Building
Mapping Functions
Data Structures
About SKILL++ and SKILL
Introducing the Cadence SKILL++ Language
What Is SKILL++?
Background of SKILL
Origins of Scheme
Scheme Is Supplied within the SKILL Environment
Relating SKILL++ to IEEE and CFI Standard Scheme
Syntax Differences
Semantic Differences
Syntax Options
Compliance Disclaimer
References
Extension Language Environment
Maintaining Existing SKILL Programs
Hiding Private Functions and Private Data with SKILL++
Specifying the Language
Contrasting Variable Scoping
SKILL++ Uses Lexical Scoping
SKILL Uses Dynamic Scoping
Example 1: Sometimes the Scoping Rules Agree
Example 2: When Dynamic and Lexical Scoping Disagree
Example 3: Calling Sequence Effects on Memory Location
Why Lexical Scoping Is Better for Reusable Code
Summary
Contrasting Symbol Usage
How SKILL Uses Symbols
How SKILL++ Uses Symbols
Contrasting the Use of Functions as Data
Assigning a Function Object to a Variable
Passing a Function as an Argument
SKILL++ Closures
Relationship to Free Variables
How SKILL++ Closures Behave
SKILL++ Environments
The Active Environment
The Top-Level Environment
Creating Environments
Functions and Environments
Persistent Environments
Using SKILL++
Introduction
Declaring Local Variables in SKILL++
Using let
Using letseq
Using letrec
Using procedure to Declare Local Functions
Sequencing and Iteration
Using begin
Using do
Using a Named let
Software Engineering with SKILL++
SKILL++ Packages
The Stack Package
Retrofitting a SKILL API as a SKILL++ Package
SKILL++ Modules
Stack Module Example
The Container Module
Using SKILL and SKILL++ Together
Introduction
Terminology
Communication Between SKILL and SKILL++
Selecting an Interactive Language
Starting an Interactive Loop (toplevel)
Exiting the Interactive Loop (resume)
Partitioning Your Source Code
Cross-Calling Guidelines
Avoid Calling SKILL Functions That Call eval, symeval, or evalstring
Avoid Calling nlambda Functions
Use the set Function with Care
Redefining Functions
Sharing Global Variables
Using importSkillVar
How importSkillVar Works
Evaluating an Expression with SKILL Semantics
Debugging SKILL++ Applications
Retrieving a Function Object (funobj)
Examining the Source Code for a Function Object
Pretty-Printing Package Functions
Inspecting Environments
Retrieving the Active Environment
Testing Variables in an Environment (boundp)
Using the -> Operator with Environments
Using the ->?? Operator with Environments
Evaluating an Expression in an Environment (eval)
Retrieving an Environment (envobj )
Examining Closures
General SKILL Debugger Commands
SKILL++ Object System
Introduction
The Common Lisp Object System
Basic Concepts
Classes and Instances
Generic Functions and Methods
Subclasses and Superclasses
Defining a Class (defclass)
Instantiating a Class (makeInstance)
Reading and Writing Instance Slots
Defining a Generic Function (defgeneric)
Defining a Method (defmethod)
Class Hierarchy
Browsing the Class Hierarchy
Getting the Class Object from the Class Name
Getting the Class Name from the Class Object
Getting the Class of an Instance
Getting the Superclasses of an Instance
Checking if an Object Is an Instance of a Class
Checking if One Class Is a Subclass of Another
Advanced Concepts
Method Argument Restrictions
Applying a Generic Function
Incremental Development
Methods versus Slots
Sharing Private Functions and Data Between Methods
Programming Examples
List Manipulation
Symbol Manipulation
Sorting a List of Points
Computing the Center of a Bounding Box
Computing the Area of a Bounding Box
Computing a Bounding Box Centered at a Point
Computing the Union of Several Bounding Boxes
Computing the Intersection of Bounding Boxes
Prime Factorizations
Evaluating a Prime Factorization
Computing the Prime Factorization
Multiplying Two Prime Factorizations
Using Prime Factorizations to Compute the GCD
Fibonacci Function
Factorial Function
Exponential Function
Counting Values in a List
Counting Characters in a String
Regular Expression Pattern Matching
Geometric Constructions
The Application Domain
The Implementation
The Classes
The Generic Functions
Describing the Methods by Class
The Source Code
Extending the Implementation
Index