summaryrefslogtreecommitdiffstats
path: root/stdlib
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-01-08 19:59:09 -0800
committerKaz Kylheku <kaz@kylheku.com>2025-01-08 19:59:09 -0800
commit58cf667aa73134c7945b0be77ed92f1c8fbc5be9 (patch)
tree3316bfb5fecf5dd4606a4427ef21b6f7fdd5988e /stdlib
parentfe633f383c53bbc080118f40dfb9443279d164f4 (diff)
downloadtxr-58cf667aa73134c7945b0be77ed92f1c8fbc5be9.tar.gz
txr-58cf667aa73134c7945b0be77ed92f1c8fbc5be9.tar.bz2
txr-58cf667aa73134c7945b0be77ed92f1c8fbc5be9.zip
lop: don't insert args when metas present.
The lop macro is inconsistent from op in that it inserts the trailing function arguments on the left even if arguments are explicitly given in the form via @1, @2, ... or @rest. This change makes lop is equivalent to op in all situations when these metas are given. * stdlib/op.tl (compat-225, compat-298): New top-level variables. (op-expand): local variable compat replaced by references to compat-225. If compat-298 is *not* in effect, then metas are checked for first in the cond, preventing the lop transformation from taking place. * tests/012/op.tl: Test cases for lop, combinations of do with lop and a few for op also. * txr.1: Redocumented, added compat notes.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/op.tl12
1 files changed, 8 insertions, 4 deletions
diff --git a/stdlib/op.tl b/stdlib/op.tl
index d1c1f3e7..a3a0135e 100644
--- a/stdlib/op.tl
+++ b/stdlib/op.tl
@@ -107,17 +107,20 @@
(defmacro op-ignerr (x)
^(sys:catch (error) ,x () (error (. args) (ignore args)))))
+(defparml compat-225 (and (plusp sys:compat) (<= sys:compat 225)))
+
+(defparml compat-298 (and (plusp sys:compat) (<= sys:compat 298)))
+
(defun sys:op-expand (f e args)
(unless args
['compile-error f "arguments required"])
- (let* ((compat (and (plusp sys:compat) (<= sys:compat 225)))
- (ctx (make-struct 'sys:op-ctx ^(form ,f)))
+ (let* ((ctx (make-struct 'sys:op-ctx ^(form ,f)))
(sys:*op-ctx* ctx)
(sym (car f))
(do-gen (if (eq sym 'do) (gensym)))
(syntax-0 (if (eq sym 'do) args ^[,*args]))
- (syntax-1 (if (or (null syntax-0) (neq sym 'do) compat)
- ;; Not do, or empty do syntax, or compat mode.
+ (syntax-1 (if (or (null syntax-0) (neq sym 'do) compat-225)
+ ;; Not do, or empty do syntax, or compat 225 mode.
(sys:op-alpha-rename e syntax-0 nil)
;; Try to expand args as-is, catching errors.
(let ((syn (op-ignerr (sys:op-alpha-rename e
@@ -161,6 +164,7 @@
(lambda-interior (let ((fargs (tree-case syntax-2
((t t . fa) fa))))
(cond
+ ((and metas (not compat-298)) syntax-2)
((and (eq sym 'lop) fargs)
(let ((fargs-l1 (mapcar (lambda (farg)
^(sys:l1-val ,farg))