definitions in expression context for guile
Fixed new-cond
06899ac8e933 — Linus Björnstam 1 year, 3 months ago
Updated examples and readme
4631d74378bc — Linus Björnstam 1 year, 3 months ago
updated readme

heads

tip
browse log

clone

read-only
https://hg.sr.ht/~bjoli/guile-define
read/write
ssh://hg@hg.sr.ht/~bjoli/guile-define

A small utility macro to allow defines in expression context of function bodies. Install it in your site-dir and import it using (use-modules (syntax define))

#Example

(use-modules (syntax def))
(define (divide-minus-one a b)
  (when (= b 1) (error "We don't allow that here"))
  (define b* (- b 1))
  (/ a b*))

This transforms all defines in expression context to (letrec ...).

#Supported forms

The bodies of begin, lambda, define, let, let*, letrec, letrec*, case and cond are transversed and transformed.

#Caveats

This is a module-local transformation, thus macros imported from other modules don't allow this transformation.

#Portability

The macros are currently written in syntax-rules. If that isn't supported in your scheme, then tough luck.

#License

Permissified ISC.

#Documentation

There is none.