]> code.delx.au - gnu-emacs-elpa/commitdiff
Add cl-letf and cl-labels.
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 22 Nov 2012 21:51:43 +0000 (16:51 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Thu, 22 Nov 2012 21:51:43 +0000 (16:51 -0500)
packages/cl-lib/cl-lib.el

index 836c554ada1f6bebf951f75962beea14306d3983..015226a935d3c2648d242bd5bebe8c3a03ed99ae 100644 (file)
@@ -4,7 +4,7 @@
 
 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
 ;; vcomment: Emacs-24.3's version is 1.0 so this has to stay below.
-;; Version: 0.1
+;; Version: 0.2
 
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
                callf2
                callf
                letf*
-               ;; letf
+               letf
                rotatef
                shiftf
                remf
                (intern (format "cl-%s" fun)))))
     (defalias new fun)))
 
+;; `cl-labels' is not 100% compatible with `labels' when using dynamic scoping
+;; (mostly because it does not turn lambdas that refer to those functions into
+;; closures).  OTOH it is compatible when using lexical scoping.
+
+(defmacro cl-labels (&rest args)
+  (if (and (boundp 'lexical-binding) lexical-binding)
+      `(labels ,@args)
+    (error "`cl-labels' with dynamic scoping is not implemented")))
+
 (provide 'cl-lib)
 ;;; cl-lib.el ends here