Pyli/set!

From Jonathan Gardner's Tech Wiki
Jump to: navigation, search

Introduction

set! is a very versatile function that accepts a wide variety of parameters.

Parameters

set! takes an even number of parameters.

(set! var-expr value ...)

The var-expr can be any number of things:

Lexical Variable name

(set! &foo 5)

This will change the value of foo in the lexical scope to 5.

Dynamic Variable Name

(set! (dynamic &foo) 5)

Element

(set! (el foo &bar) 5)
(set! (el (el (el foo &bar) &bo) &baz) 5)
(set! (el (el (el (dynamic &foo) &bar) &bo) &baz 5)

This is handled as:

(set! (el foo &bar) 5) => (foo.set-el &bar 5)

Attribute

(set! (attr foo &bar) 5) => (foo.set-attr &bar 5)