https://github.com/stylewarning/letrec
https://github.com/stylewarning/letrec
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/stylewarning/letrec
- Owner: stylewarning
- License: other
- Created: 2023-04-09T22:08:19.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-04-09T22:21:56.000Z (about 3 years ago)
- Last Synced: 2025-10-27T08:59:09.501Z (8 months ago)
- Language: Common Lisp
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: LICENSE
Awesome Lists containing this project
README
LETREC
======
Robert Smith
INTRODUCTION
------------
LETREC:LETREC is a macro which aims to imitate Scheme's letrec
form. It is a useful construct for functional programming in Common
Lisp, where you have function-producing forms which need to be
functionally bound to a symbol.
EXAMPLE
-------
The following code
(defun multiplier (n)
(lambda (x) (* n x)))
(letrec ((double (multiplier 2))
(triple (multiplier 3)))
(double (triple 5)))
produces
30.
Another example:
(letrec:letrec ((double (multiplier 2)))
(double (funcall #'double 5)))
produces
20.
ISSUES
------
Unforunately, the macro isn't a very efficient implementation. There
is a level of indirection with the function calling. Essentially, a
LETREC with the binding
(name fn)
is expanded to a LABELS binding of the form
(name (&rest args)
(apply fn args))
which is somewhat abysmal.
Patches are welcome for implementation-specific ways of implementing
the macro.