History

make "lambda" a full synonym of "λ"

Sigrid Solveig Haflínudóttir committed 1 year ago

Commit 3efd6251 parent 06f3f235 files · +26 −31Browse files

Unified · Split

5 files
  1. boot/sl.boot +16 −17
  2. src/compiler.sl +6 −10
  3. src/read.c +1 −3
  4. src/sl.c +3 −0
  5. src/system.sl +0 −1
boot/sl.boot+16−17
@@ -104,7 +104,7 @@ · 103 unmodified lines
104104 #:g430 λ prog1 trycatch #:g431 raise)) dotimes #fn("z10<0T20E2187Ke32223e186e1e12415153e4:" #(for
105105 - #fn(nconc) λ #fn(copy-list))) throw #fn("n220212223e201e4e2:" #(raise list quote thrown-value)))
106106 1+ #fn("n10KM:" #() 1+) 1-
107− #fn("n10K~:" #() 1-) 1arg-lambda? #fn("n10B;3E04700<51;3:04710TK62:" #(lambda? length=) 1arg-lambda?)
107+ #fn("n10K~:" #() 1-) 1arg-lambda? #fn("n10B;3D040<20Q;3:04710TK62:" #(λ length=) 1arg-lambda?)
108108 <= #fn("z1Ib6862086>1_486<^10162:" #(#fn("n21S;JL041<0L2;J5040V340q:A<1<1=62:")) <=) >
109109 #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:")) >=)
110110 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 @@ · 55 unmodified lines
166166 #fn("n10==:" #() cddr) closure? #fn("n10\\;36040[S:" #() closure?) compile
167167 #fn("n170q7105162:" #(compile-f lower-define) compile) compile-and #fn("n570018283D218467:" #(compile-short-circuit
168168 brn) compile-and)
169− 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?
169+ 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?
170170 #fn(top-level-value) length> 255 compile-in compile-arglist emit tcall.l call.l
171− builtin->instruction cadr length= lambda? inlineable? compile-let compile-builtin-call tcall call) compile-app)
171+ builtin->instruction cadr length= λ inlineable? compile-let compile-builtin-call tcall call) compile-app)
172172 compile-arglist #fn("n3202101>282524228261:" #(#fn(for-each)
173173 #fn("n170AFq0544Ar4Ar4GKMp:" #(compile-in))
174174 #fn(length)) compile-arglist)
@@ -191,15 +191,15 @@ · 16 unmodified lines
191191 const-to-idx-vec) compile-f-)
192192 compile-if #fn("n420502050205083T718351728351B3;0738351@30q8;DC=07401828<64:8;J=07401828=64:7401q8;89554750268953475027885347401828<544823<07502852@;0750298:53475027895347401828=544750278:63:" #(#fn(gensym)
193193 caddr cdddr cadddr compile-in emit brn label ret jmp) compile-if)
194− 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
194+ 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
195195 emit load0 load1 loadt loadnil void? loadvoid fits-i8 loadi8 loadv aset! compile-aset! in-env?
196196 compile-app quote self-evaluating? compile-in if compile-if begin compile-begin prog1
197197 compile-prog1 λ call-with-values #fn("n070AF62:" #(compile-f-))
198198 #fn("n270A21053413K02223AF>2152470A242515163:q:" #(emit loadv #fn(for-each)
199199 #fn("n170AF0q64:" #(compile-sym)) closure #fn(length)))
200200 and compile-and or compile-or while compile-while cddr return ret set! separate-doc-from-body
201− error "set!: name must be a symbol" sym-set-doc lambda? lambda:vars compile-set! trycatch
202− 1arg-lambda? caddr "trycatch: second form must be a 1-argument lambda") compile-in)
201+ error "set!: name must be a symbol" sym-set-doc lambda:vars compile-set! trycatch 1arg-lambda?
202+ caddr "trycatch: second form must be a 1-argument lambda") compile-in)
203203 compile-let #fn("n483<83=0r4G88T70018953718;727388518;528:537408=524258=1<521=P7608>827388515440r40r4G8<UMp4E8<L23A082J<0770288<63:q:" #(compile-arglist
204204 vars-to-env complex-bindings caddr box-vars #fn(nconc) compile-in emit shift) compile-let)
205205 compile-or #fn("n470018283q21q67:" #(compile-short-circuit brnn) compile-or)
@@ -220,9 +220,9 @@ · 14 unmodified lines
220220 complex-bindings-
221221 filter #fn("n120A062:" #(#fn(has?)))
222222 table-keys) complex-bindings)
223− 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)
224− #fn(put!) quoted? set! complex-bindings- caddr lambda? lambda:body diff lambda:vars inlineable?
225− #fn(map) #fn("n1700AqF929366:" #(complex-bindings-))) complex-bindings-)
223+ 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)
224+ #fn(put!) quoted? set! complex-bindings- caddr λ lambda:body diff lambda:vars inlineable? #fn(map)
225+ #fn("n1700AqF929366:" #(complex-bindings-))) complex-bindings-)
226226 const-to-idx-vec #fn("n1200r2G51212285>10KG52485:" #(#fn(vec-alloc)
227227 #fn(for-each)
228228 #fn("n2A10p:")) const-to-idx-vec)
@@ -292,7 +292,7 @@ · 63 unmodified lines
292292 #fn("n10:" #() identity) in-env? #fn("n21B;3F042001<52;J:047101=62:" #(#fn(assq)
293293 in-env?) in-env?)
294294 index-of #fn("n31J40q:01<C5082:7001=82KM63:" #(index-of) index-of) inlineable?
295− #fn("n10<85B;3u047085<51;3i047185T51;3]04727385T52;3O047485T2552S;3@047685T270=5162:" #(lambda?
295+ #fn("n10<85B;3t0485<20Q;3i047185T51;3]04727385T52;3O047485T2552S;3@047685T270=5162:" #(λ
296296 list? every sym? length> 255 length= #fn(length)) inlineable?)
297297 io-readall #fn("n1205021850524228561:" #(#fn(buffer)
298298 #fn(io-copy)
@@ -315,10 +315,9 @@ · 16 unmodified lines
315315 #fn("n10B390700<61:0:" #(keyword->sym))
316316 to-proper) lambda-vars)
317317 lambda:body #fn("n170061:" #(caddr) lambda:body) lambda:vars
318− #fn("n1700T61:" #(lambda-vars) lambda:vars) lambda? #fn("n1020Q;J704020Q:" #(λ) lambda?)
319− last-pair #fn("n10=H3400:700=61:" #(last-pair) last-pair) lastcdr
320− #fn("n10H3400:70051=:" #(last-pair) lastcdr) length= #fn("n21EL2340q:1El23500H:0H3701El2:700=1K~62:" #(length=) length=)
321− length> #fn("n21EL23400:1El23;00B;34040:0H3701EL2:700=1K~62:" #(length>) length>)
318+ #fn("n1700T61:" #(lambda-vars) lambda:vars) last-pair #fn("n10=H3400:700=61:" #(last-pair) last-pair)
319+ lastcdr #fn("n10H3400:70051=:" #(last-pair) lastcdr) length=
320+ #fn("n21EL2340q:1El23500H:0H3701El2:700=1K~62:" #(length=) length=) length> #fn("n21EL23400:1El23;00B;34040:0H3701EL2:700=1K~62:" #(length>) length>)
322321 list->vec #fn("n1700}2:" #(vec) list->vec) list-head
323322 #fn("n2E1L2;3?040<700=1K~52P:" #(list-head) list-head) list-ref #fn("n2700152<:" #(list-tail) list-ref)
324323 list-tail #fn("n2701E523400:710=1K~62:" #(<= list-tail) list-tail) list?
@@ -328,10 +327,10 @@ · 3 unmodified lines
328327 #fn(raise) load-error))) load)
329328 load-process #fn("n170061:" #(eval) load-process) lookup-sym
330329 #fn("n31J5020:1<2108752883808288P:7201=82KM63:" #(global #fn(assq) lookup-sym) lookup-sym)
331− lower-define #fn("n1I2021?55140H;J804720513400:0<23C<0747505161:760<513K02728e10Te185051e17905164:2:74062:" #(#1#
330+ lower-define #fn("n1I2021?55140H;J804720513400:0<23C<0747505161:0<26CK02726e10Te185051e17805164:2974062:" #(#1#
332331 #fn("n170051B3N071051B3=02270051P@7073051@607450758551768551863D0278687e328748652P:87:" #(cddr
333332 cdddr begin caddr void get-defined-vars lower-define λ #fn(map)) λ-body) quoted? def lower-define
334− expand-define lambda? #fn(nconc) λ lastcdr #fn(map)) lower-define)
333+ expand-define λ #fn(nconc) lastcdr #fn(map)) lower-define)
335334 macrocall? #fn("n10<R;3904700<61:" #(get-syntax) macrocall?) macroexpand
336335 #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#
337336 #fn("n20Z;J904200152S:" #(#fn(assq)) top?) #fn("n10H3400:020d3400:0<B3P07105122CF023A<7405151A<0=5162:0<A<0=51P:" #(((begin))
@@ -348,7 +347,7 @@ · 10 unmodified lines
348347 #fn(map) list) expand-define) #fn("n20T20A<71051222324F1>2865215252P:" #(begin cddr #fn(nconc)
349348 #fn(map)
350349 #fn("n10<70A<0TF525150Fe3:" #(compile-thunk))) expand-let-syntax)
351− #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)
350+ #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)
352351 #fn("n0Ib48420AF84>3_484<^19261:" #(#fn("n10H3400:0<H3700<@90A<0<F5292<0=51P:"))) caddr
353352 macrocall? quote λ def let-syntax) expand-in)) macroexpand)
354353 macroexpand-1 #fn("n10H3400:7005185390850=}2:0:" #(macrocall?) macroexpand-1)
src/compiler.sl+6−10
@@ -305,13 +305,9 @@ · 304 unmodified lines
305305 (emit g 'jmp top)
306306 (mark-label g end)))
307307
308−(def (lambda? a)
309− (or (eq? a 'λ)
310− (eq? a 'lambda)))
311−
312308 (def (1arg-lambda? func)
313309 (and (cons? func)
314− (lambda? (car func))
310+ (eq? (car func) 'λ)
315311 (length= (cadr func) 1)))
316312
317313 (def (compile-short-circuit g env tail? forms default branch outl)
@@ -406,7 +402,7 @@ · 88 unmodified lines
406402 (def (inlineable? form)
407403 (let ((lam (car form)))
408404 (and (cons? lam)
409− (lambda? (car lam))
405+ (eq? (car lam) 'λ)
410406 (list? (cadr lam))
411407 (every sym? (cadr lam))
412408 (not (length> (cadr lam) 255))
@@ -455,7 +451,7 @@ · 42 unmodified lines
455451 (begin (compile-in g env NIL (cadr x))
456452 (emit g 'cadr))
457453 (if (and (cons? head)
458− (lambda? (car head))
454+ (eq? (car head) 'λ)
459455 (inlineable? x))
460456 (compile-let g env tail? x)
461457 (begin
@@ -515,7 +511,7 @@ · 53 unmodified lines
515511 (error "set!: name must be a symbol"))
516512 (when doc
517513 (sym-set-doc name doc (and (cons? (car value))
518− (lambda? (car (car value)))
514+ (eq? (car (car value)) 'λ)
519515 (lambda:vars (car value)))))
520516 (compile-set! g env name (car value))))
521517 (trycatch (compile-in g env NIL `(λ () ,(cadr x)))
@@ -626,7 +622,7 @@ · 104 unmodified lines
626622 e)
627623 ((eq? (car e) 'def)
628624 (lower-define (expand-define e)))
629− ((lambda? (car e))
625+ ((eq? (car e) 'λ)
630626 `(λ ,(cadr e) ,(λ-body e) . ,(lastcdr e)))
631627 (else
632628 (map lower-define e))))
@@ -653,7 +649,7 @@ · 20 unmodified lines
653649 (put! setd (cadr e) T)
654650 (if nested (put! capt (cadr e) T)))
655651 (complex-bindings- (caddr e) vars NIL nested capt setd))
656− ((lambda? (car e))
652+ ((eq? (car e) 'λ)
657653 (complex-bindings- (lambda:body e)
658654 (diff vars (lambda:vars e))
659655 NIL
src/read.c+1−3
@@ -376,7 +376,7 @@ peek(Rctx *ctx) · 375 unmodified lines
376376 bool ok = read_token(ctx, c, 0);
377377 const char *s = ctx->buf;
378378 if(!ok){
379− if(s[0] == '.' && s[1] == '\0'){
379+ if(s[0] == '.' && s[1] == 0){
380380 ctx->ws = false;
381381 return (ctx->toktype = TOK_DOT);
382382 }
@@ -390,8 +390,6 @@ peek(Rctx *ctx) · 7 unmodified lines
390390 ctx->tokval = sl_nil;
391391 else if(s[1] == 0 && (s[0] == 't' || s[0] == 'T'))
392392 ctx->tokval = sl_t;
393− else if(strcmp(s, "λ") == 0 || strcmp(s, "lambda") == 0)
394− ctx->tokval = sl_lambda;
395393 else{
396394 ctx->tokval = mk_sym(s, true);
397395 if(s[strlen(s)-1] == '#')
src/sl.c+3−0
@@ -244,6 +244,8 @@ mk_sym(const char *str, bool copy) · 243 unmodified lines
244244 v = alloc_sym(str, len, copy);
245245 slg.symbols = Tsetl(slg.symbols, v->name, len, v);
246246 }
247+ if(v->binding == sl_lambda)
248+ return sl_lambda;
247249 return tagptr(v, TAG_SYM);
248250 }
249251
@@ -1259,6 +1261,7 @@ failed: · 1009 unmodified lines
12591261 comparehash_init();
12601262
12611263 sl_lambda = mk_csym("λ");
1264+ setc(mk_csym("lambda"), sl_lambda);
12621265 sl_quote = mk_csym("quote");
12631266 sl_trycatch = mk_csym("trycatch");
12641267 sl_backquote = mk_csym("quasiquote");
src/system.sl+0−1
@@ -1315,7 +1315,6 @@ · 1314 unmodified lines
13151315 (default))
13161316 ((eq? head 'quote) e)
13171317 ((eq? head 'λ) (expand-lambda e env))
1318− ((eq? head 'lambda) (expand-lambda e env))
13191318 ((eq? head 'def) (expand-define e env))
13201319 ((eq? head 'let-syntax) (expand-let-syntax e env))
13211320 (else (default))))))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t