ref: 3efd625f94ba38fb5c37499441fdad603db25cd3
parent: 06f3f23530c137bac805f97166bbfab32a392644
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Mar 25 16:38:25 EDT 2025
make "lambda" a full synonym of "λ"
--- a/boot/sl.boot
+++ b/boot/sl.boot
@@ -104,7 +104,7 @@
#:g430 λ prog1 trycatch #:g431 raise)) dotimes #fn("z10<0T20E2187Ke32223e186e1e12415153e4:" #(for
- #fn(nconc) λ #fn(copy-list))) throw #fn("n220212223e201e4e2:" #(raise list quote thrown-value)))
1+ #fn("n10KM:" #() 1+) 1-
- #fn("n10K~:" #() 1-) 1arg-lambda? #fn("n10B;3E04700<51;3:04710TK62:" #(lambda? length=) 1arg-lambda?)
+ #fn("n10K~:" #() 1-) 1arg-lambda? #fn("n10B;3D040<20Q;3:04710TK62:" #(λ length=) 1arg-lambda?)
<= #fn("z1Ib6862086>1_486<^10162:" #(#fn("n21S;JL041<0L2;J5040V340q:A<1<1=62:")) <=) >
#fn("z1Ib6862086>1_486<^10162:" #(#fn("n21S;JE041<0L2;3;04A<1<1=62:")) >) >= #fn("z1Ib6862086>1_486<^10162:" #(#fn("n21S;JL0401<L2;J5040V340q:A<1<1=62:")) >=)
Instructions #table(call.l #byte(0x51) trycatch #byte(0x4b) loadg.l #byte(0x44) aref2 #byte(0x17) box #byte(0x32) cadr #byte(0x24) argc #byte(0x3e) setg #byte(0x47) load0 #byte(0x15) nan? #byte(0x26) fixnum? #byte(0x29) loadc0 #byte(0x11) loada0 #byte(0x0) div0 #byte(0x3b) keyargs #byte(0x1f) call #byte(0x5) loada.l #byte(0x45) num? #byte(0x28) sub2 #byte(0x4e) add2 #byte(0x1d) loadc.l #byte(0x46) loadc #byte(0x9) builtin? #byte(0x2b) set-car! #byte(0x2f) vargc.l #byte(0x50) vec #byte(0x3f) ret #byte(0xa) loadi8 #byte(0x42) tapply #byte(0x4d) loadvoid #byte(0x19) loada1 #byte(0x1) shift #byte(0x2e) atom? #byte(0x18) cdr #byte(0xd) brne.l #byte(0x53) / #byte(0x3a) equal? #byte(0x34) apply #byte(0x36) dup #byte(0xb) loadt #byte(0x14) jmp.l #byte(0x30) = #byte(0x3c) not #byte(0x23) set-cdr! #byte(0x1e) fn? #byte(0x2c) eq? #byte(0x21) * #byte(0x39) load1 #byte(0x1b) bound? #byte(0x2a) box.l #byte(0x56) < #byte(0x1c) brnn.l #byte(0x54) jmp #byte(0x10) loadv #byte(0x2) for #byte(0x4c) dummy_eof #byte(0x58) + #byte(0x37) brne #byte(0x13) argc.l #byte(0x4f) compare #byte(0x3d) brn #byte(0x3) neg #byte(0x25) loadv.l #byte(0x43) vargc #byte(0x4a) brbound #byte(0x27) loadc1 #byte(0x16) setg.l #byte(0x48) cons? #byte(0x12) aref #byte(0x55) sym? #byte(0x22) aset! #byte(0x40) car #byte(0xc) cons #byte(0x20) tcall.l #byte(0x52) - #byte(0x38) brn.l #byte(0x31) optargs #byte(0x57) closure #byte(0xe) vec? #byte(0x2d) pop #byte(0x4) eqv? #byte(0x33) list #byte(0x35) seta #byte(0xf) seta.l #byte(0x49) brnn #byte(0x1a) loadnil #byte(0x41) loadg #byte(0x7) loada #byte(0x8) tcall #byte(0x6))
@@ -166,9 +166,9 @@
#fn("n10==:" #() cddr) closure? #fn("n10\\;36040[S:" #() closure?) compile
#fn("n170q7105162:" #(compile-f lower-define) compile) compile-and #fn("n570018283D218467:" #(compile-short-circuit
brn) compile-and)
- compile-app #fn("n483<88R3U07088152JK088Z3E0218851[3;0218851@40887283=23523q07401q895440r40r4GKMp4750183=530r40r4G8:UMp47608237027@40288:63:89[;3904798951892:Cf07089152J\\0212:517:d3P07;83r2523E07401q83T5447602:62:89B3P07<89<513F07=83513=07>01828364:8:360q@F07401q895440r40r4GKMp4750183=530r40r4G8;UMp48:360q@=00r40r4Gr/Mp48:3C07?018283898:8;67:760823702@@402A8;63:" #(in-env?
+ compile-app #fn("n483<88R3U07088152JK088Z3E0218851[3;0218851@40887283=23523q07401q895440r40r4GKMp4750183=530r40r4G8:UMp47608237027@40288:63:89[;3904798951892:Cf07089152J\\0212:517:d3P07;83r2523E07401q83T5447602:62:89B3N089<2<CF07=83513=07>01828364:8:360q@F07401q895440r40r4GKMp4750183=530r40r4G8;UMp48:360q@=00r40r4Gr/Mp48:3C07?018283898:8;67:760823702@@402A8;63:" #(in-env?
#fn(top-level-value) length> 255 compile-in compile-arglist emit tcall.l call.l
- builtin->instruction cadr length= lambda? inlineable? compile-let compile-builtin-call tcall call) compile-app)
+ builtin->instruction cadr length= λ inlineable? compile-let compile-builtin-call tcall call) compile-app)
compile-arglist #fn("n3202101>282524228261:" #(#fn(for-each)
#fn("n170AFq0544Ar4Ar4GKMp:" #(compile-in))
#fn(length)) compile-arglist)
@@ -191,7 +191,7 @@
const-to-idx-vec) compile-f-)
compile-if #fn("n420502050205083T718351728351B3;0738351@30q8;DC=07401828<64:8;J=07401828=64:7401q8;89554750268953475027885347401828<544823<07502852@;0750298:53475027895347401828=544750278:63:" #(#fn(gensym)
caddr cdddr cadddr compile-in emit brn label ret jmp) compile-if)
- compile-in #fn("\x8740005000W4000J60q?4483R3<0700183D64:83H3\x97083EC:07102262:83KC:07102362:83DC:07102462:83J:07102562:7683513:07102762:7883513<0710298363:7102:8363:83<2;C<07<0183=63:83<RS;JD0483<Z;J;047=83<1523=07>01828364:83<892?CS07@83T513>07A018283T64:7102:83T63:892BC=07C01828364:892DC>07E018283=64:892FC;07G018363:892HCD07I2J183>22K01>262:892LC@07M018283=8465:892NC>07O018283=64:892PCE07Q0183T2D7R8351P64:892SCE07A01D83T5447102T62:892UC\x92083T7V7R8351518;<<8;=8:R360q@807W2X5148<3Z07Y8:8<8=<B;3G047Z8=<<51;3:047[8=<5153@30q47\\018:8=<64:892]Cp07A01q2Hq83Te35447^7_835151360q@807W2`5147A01q7_83515447102]62:7>01828364:" #(compile-sym
+ compile-in #fn("\x8740005000W4000J60q?4483R3<0700183D64:83H3\x97083EC:07102262:83KC:07102362:83DC:07102462:83J:07102562:7683513:07102762:7883513<0710298363:7102:8363:83<2;C<07<0183=63:83<RS;JD0483<Z;J;047=83<1523=07>01828364:83<892?CS07@83T513>07A018283T64:7102:83T63:892BC=07C01828364:892DC>07E018283=64:892FC;07G018363:892HCD07I2J183>22K01>262:892LC@07M018283=8465:892NC>07O018283=64:892PCE07Q0183T2D7R8351P64:892SCE07A01D83T5447102T62:892UC\x91083T7V7R8351518;<<8;=8:R360q@807W2X5148<3Y07Y8:8<8=<B;3F048=<<2HQ;3:047Z8=<5153@30q47[018:8=<64:892\\Cp07A01q2Hq83Te35447]7^835151360q@807W2_5147A01q7^83515447102\\62:7>01828364:" #(compile-sym
emit load0 load1 loadt loadnil void? loadvoid fits-i8 loadi8 loadv aset! compile-aset! in-env?
compile-app quote self-evaluating? compile-in if compile-if begin compile-begin prog1
compile-prog1 λ call-with-values #fn("n070AF62:" #(compile-f-))
@@ -198,8 +198,8 @@
#fn("n270A21053413K02223AF>2152470A242515163:q:" #(emit loadv #fn(for-each)
#fn("n170AF0q64:" #(compile-sym)) closure #fn(length)))
and compile-and or compile-or while compile-while cddr return ret set! separate-doc-from-body
- error "set!: name must be a symbol" sym-set-doc lambda? lambda:vars compile-set! trycatch
- 1arg-lambda? caddr "trycatch: second form must be a 1-argument lambda") compile-in)
+ error "set!: name must be a symbol" sym-set-doc lambda:vars compile-set! trycatch 1arg-lambda?
+ caddr "trycatch: second form must be a 1-argument lambda") compile-in)
compile-let #fn("n483<83=0r4G88T70018953718;727388518;528:537408=524258=1<521=P7608>827388515440r40r4G8<UMp4E8<L23A082J<0770288<63:q:" #(compile-arglist
vars-to-env complex-bindings caddr box-vars #fn(nconc) compile-in emit shift) compile-let)
compile-or #fn("n470018283q21q67:" #(compile-short-circuit brnn) compile-or)
@@ -220,9 +220,9 @@
complex-bindings-
filter #fn("n120A062:" #(#fn(has?)))
table-keys) complex-bindings)
- complex-bindings- #fn("n61J40q:0R3K0833D02001523;021840D63:q:0H;J80472051340q:0<23Co0200T1523Q021850TD534833>021840TD53@30q@30q474750511q83848566:760<513U074770517817905152q82S;J50483848566:740<17:051838485562;2<1838485>40=52P:" #(#fn(memq)
- #fn(put!) quoted? set! complex-bindings- caddr lambda? lambda:body diff lambda:vars inlineable?
- #fn(map) #fn("n1700AqF929366:" #(complex-bindings-))) complex-bindings-)
+ complex-bindings- #fn("n61J40q:0R3K0833D02001523;021840D63:q:0H;J80472051340q:0<23Co0200T1523Q021850TD534833>021840TD53@30q@30q474750511q83848566:0<26CU074770517817905152q82S;J50483848566:740<17:051838485562;2<1838485>40=52P:" #(#fn(memq)
+ #fn(put!) quoted? set! complex-bindings- caddr λ lambda:body diff lambda:vars inlineable? #fn(map)
+ #fn("n1700AqF929366:" #(complex-bindings-))) complex-bindings-)
const-to-idx-vec #fn("n1200r2G51212285>10KG52485:" #(#fn(vec-alloc)
#fn(for-each)
#fn("n2A10p:")) const-to-idx-vec)
@@ -292,7 +292,7 @@
#fn("n10:" #() identity) in-env? #fn("n21B;3F042001<52;J:047101=62:" #(#fn(assq)
in-env?) in-env?)
index-of #fn("n31J40q:01<C5082:7001=82KM63:" #(index-of) index-of) inlineable?
- #fn("n10<85B;3u047085<51;3i047185T51;3]04727385T52;3O047485T2552S;3@047685T270=5162:" #(lambda?
+ #fn("n10<85B;3t0485<20Q;3i047185T51;3]04727385T52;3O047485T2552S;3@047685T270=5162:" #(λ
list? every sym? length> 255 length= #fn(length)) inlineable?)
io-readall #fn("n1205021850524228561:" #(#fn(buffer)
#fn(io-copy)
@@ -315,10 +315,9 @@
#fn("n10B390700<61:0:" #(keyword->sym))
to-proper) lambda-vars)
lambda:body #fn("n170061:" #(caddr) lambda:body) lambda:vars
- #fn("n1700T61:" #(lambda-vars) lambda:vars) lambda? #fn("n1020Q;J704020Q:" #(λ) lambda?)
- last-pair #fn("n10=H3400:700=61:" #(last-pair) last-pair) lastcdr
- #fn("n10H3400:70051=:" #(last-pair) lastcdr) length= #fn("n21EL2340q:1El23500H:0H3701El2:700=1K~62:" #(length=) length=)
- length> #fn("n21EL23400:1El23;00B;34040:0H3701EL2:700=1K~62:" #(length>) length>)
+ #fn("n1700T61:" #(lambda-vars) lambda:vars) last-pair #fn("n10=H3400:700=61:" #(last-pair) last-pair)
+ lastcdr #fn("n10H3400:70051=:" #(last-pair) lastcdr) length=
+ #fn("n21EL2340q:1El23500H:0H3701El2:700=1K~62:" #(length=) length=) length> #fn("n21EL23400:1El23;00B;34040:0H3701EL2:700=1K~62:" #(length>) length>)
list->vec #fn("n1700}2:" #(vec) list->vec) list-head
#fn("n2E1L2;3?040<700=1K~52P:" #(list-head) list-head) list-ref #fn("n2700152<:" #(list-tail) list-ref)
list-tail #fn("n2701E523400:710=1K~62:" #(<= list-tail) list-tail) list?
@@ -328,10 +327,10 @@
#fn(raise) load-error))) load)
load-process #fn("n170061:" #(eval) load-process) lookup-sym
#fn("n31J5020:1<2108752883808288P:7201=82KM63:" #(global #fn(assq) lookup-sym) lookup-sym)
- lower-define #fn("n1I2021?55140H;J804720513400:0<23C<0747505161:760<513K02728e10Te185051e17905164:2:74062:" #(#1#
+ lower-define #fn("n1I2021?55140H;J804720513400:0<23C<0747505161:0<26CK02726e10Te185051e17805164:2974062:" #(#1#
#fn("n170051B3N071051B3=02270051P@7073051@607450758551768551863D0278687e328748652P:87:" #(cddr
cdddr begin caddr void get-defined-vars lower-define λ #fn(map)) λ-body) quoted? def lower-define
- expand-define lambda? #fn(nconc) λ lastcdr #fn(map)) lower-define)
+ expand-define λ #fn(nconc) lastcdr #fn(map)) lower-define)
macrocall? #fn("n10<R;3904700<61:" #(get-syntax) macrocall?) macroexpand
#fn("n1IIIIIIIIIIIb5b6b7b8b9b:b;b<b=b>b?208521_51420862286>1_514208723e1_51420882485868?87>4_5142089258?89>2_514208:268:>1_514208;278:8988>3_514208<288?8:8988>4_514208=29888?>2_514208>2:_514208?2;8?8>8;8<8=>5_5148?<0q62:" #(#0#
#fn("n20Z;J904200152S:" #(#fn(assq)) top?) #fn("n10H3400:020d3400:0<B3P07105122CF023A<7405151A<0=5162:0<A<0=51P:" #(((begin))
@@ -348,7 +347,7 @@
#fn(map) list) expand-define) #fn("n20T20A<71051222324F1>2865215252P:" #(begin cddr #fn(nconc)
#fn(map)
#fn("n10<70A<0TF525150Fe3:" #(compile-thunk))) expand-let-syntax)
- #fn("n20:" #() local-expansion-env) #fn("n20H3400:0<208615221A10>3873P087=B3I0A<87T0=f2F<72875115262:73051893>0A<890=f2162:87;J?0486RS;J60486Z3708860:8624C400:8625C:092<0162:8625C:092<0162:8626C:093<0162:8627C:094<0162:8860:" #(#fn(assq)
+ #fn("n20:" #() local-expansion-env) #fn("n20H3400:0<208615221A10>3873P087=B3I0A<87T0=f2F<72875115262:73051893>0A<890=f2162:87;J?0486RS;J60486Z3708860:8624C400:8625C:092<0162:8626C:093<0162:8627C:094<0162:8860:" #(#fn(assq)
#fn("n0Ib48420AF84>3_484<^19261:" #(#fn("n10H3400:0<H3700<@90A<0<F5292<0=51P:"))) caddr
macrocall? quote λ def let-syntax) expand-in)) macroexpand)
macroexpand-1 #fn("n10H3400:7005185390850=}2:0:" #(macrocall?) macroexpand-1)
--- a/src/compiler.sl
+++ b/src/compiler.sl
@@ -305,13 +305,9 @@
(emit g 'jmp top)
(mark-label g end)))
-(def (lambda? a)
- (or (eq? a 'λ)
- (eq? a 'lambda)))
-
(def (1arg-lambda? func)
(and (cons? func)
- (lambda? (car func))
+ (eq? (car func) 'λ)
(length= (cadr func) 1)))
(def (compile-short-circuit g env tail? forms default branch outl)
@@ -406,7 +402,7 @@
(def (inlineable? form)
(let ((lam (car form)))
(and (cons? lam)
- (lambda? (car lam))
+ (eq? (car lam) 'λ)
(list? (cadr lam))
(every sym? (cadr lam))
(not (length> (cadr lam) 255))
@@ -455,7 +451,7 @@
(begin (compile-in g env NIL (cadr x))
(emit g 'cadr))
(if (and (cons? head)
- (lambda? (car head))
+ (eq? (car head) 'λ)
(inlineable? x))
(compile-let g env tail? x)
(begin
@@ -515,7 +511,7 @@
(error "set!: name must be a symbol"))
(when doc
(sym-set-doc name doc (and (cons? (car value))
- (lambda? (car (car value)))
+ (eq? (car (car value)) 'λ)
(lambda:vars (car value)))))
(compile-set! g env name (car value))))
(trycatch (compile-in g env NIL `(λ () ,(cadr x)))
@@ -626,7 +622,7 @@
e)
((eq? (car e) 'def)
(lower-define (expand-define e)))
- ((lambda? (car e))
+ ((eq? (car e) 'λ)
`(λ ,(cadr e) ,(λ-body e) . ,(lastcdr e)))
(else
(map lower-define e))))
@@ -653,7 +649,7 @@
(put! setd (cadr e) T)
(if nested (put! capt (cadr e) T)))
(complex-bindings- (caddr e) vars NIL nested capt setd))
- ((lambda? (car e))
+ ((eq? (car e) 'λ)
(complex-bindings- (lambda:body e)
(diff vars (lambda:vars e))
NIL
--- a/src/read.c
+++ b/src/read.c
@@ -376,7 +376,7 @@
bool ok = read_token(ctx, c, 0);
const char *s = ctx->buf;
if(!ok){
- if(s[0] == '.' && s[1] == '\0'){
+ if(s[0] == '.' && s[1] == 0){
ctx->ws = false;
return (ctx->toktype = TOK_DOT);
}
@@ -390,8 +390,6 @@
ctx->tokval = sl_nil;
else if(s[1] == 0 && (s[0] == 't' || s[0] == 'T'))
ctx->tokval = sl_t;
- else if(strcmp(s, "λ") == 0 || strcmp(s, "lambda") == 0)
- ctx->tokval = sl_lambda;
else{
ctx->tokval = mk_sym(s, true);
if(s[strlen(s)-1] == '#')
--- a/src/sl.c
+++ b/src/sl.c
@@ -244,6 +244,8 @@
v = alloc_sym(str, len, copy);
slg.symbols = Tsetl(slg.symbols, v->name, len, v);
}
+ if(v->binding == sl_lambda)
+ return sl_lambda;
return tagptr(v, TAG_SYM);
}
@@ -1259,6 +1261,7 @@
comparehash_init();
sl_lambda = mk_csym("λ");
+ setc(mk_csym("lambda"), sl_lambda);
sl_quote = mk_csym("quote");
sl_trycatch = mk_csym("trycatch");
sl_backquote = mk_csym("quasiquote");
--- a/src/system.sl
+++ b/src/system.sl
@@ -1315,7 +1315,6 @@
(default))
((eq? head 'quote) e)
((eq? head 'λ) (expand-lambda e env))
- ((eq? head 'lambda) (expand-lambda e env))
((eq? head 'def) (expand-define e env))
((eq? head 'let-syntax) (expand-let-syntax e env))
(else (default))))))