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

define_syntax

define_syntax( 
s_name 
g_expander ... 
)
=> s_name

Description

Creates a syntax rule using the syntax_rule expander form.

Arguments

s_name

Name of the syntax rule.

g_expander

Expander form, which can be of the form (syntax_rules (...) ...).

Value Returned

s_name

A macro expression, which evaluates to a single argument procedure that performs the specified syntactic transformation.

Examples

(define_syntax incf
    (syntax_rules ()
     ((_ location) (setf location (add1 location)))
((_ location amount) (setf location (plus location amount)))))
=> incf
x=3 => 3
(incf x) => 4
x => 4
(incf x 3) => 7
x => 7
x='(1 2 3) => (1 2 3)
(incf (cadr x)) => 3
x => (1 3 3)
(incf (car x) 5) => 6
x => (6 3 3)

Related Topics

Function and Program Structure


Return to top
 ⠀
X