Pyli/Methods/Variables

From Jonathan Gardner's Tech Wiki
< Pyli‎ | Methods
Jump to: navigation, search

Variables

Declaring new functionality:

  • (defn fn-name (args) body...): Defines a global function.
  • (defmacro macro-name (args) body...): Defines a global macro.
  • (defclass ...): A new class
  • (defgenmethod ...): A new generic method.
  • (defmethod ...): A new method.

Declaring lexical variables:

  • (let (var value ...) body...): Execute body with var defined as value. In parallel.
  • (let* (var value ...) body...): Idem, but in series.
  • (let dict body...): Uses dict as the lexical scope. Changes are preserved.

Declaring global variables:

  • (def var value...): Define the variables var with values value in parallel.
  • (def* var value...): Idem, but in series.
  • (def dict): Promote the keys and values in the dict to the global level.

Changing variable values: Note that the var can be an expression.

  • (setf var value ...): Set the vars to values, in parallel.
  • (setf* var value var value): Idem, but in series.

Creating an alias: (Need a way for some values to eval twice, automatically.)

  • ...