shithub: sl

Download patch

ref: 8b457cd416da8e0351f79968d5134455077a5c99
parent: c37206a50fffdbe6e4efc37e75dfaa47f3da59af
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon Apr 14 13:24:46 EDT 2025

typeof → type-of

--- a/boot/sl.boot
+++ b/boot/sl.boot
@@ -89,7 +89,7 @@
   #fn(map) #fn("n10B3500<:0:") #fn(sym) #\? "make-" #fn(str) "-" #fn("n12002152853=0220E8553@300853<02208552@40232486252627e1A360q@7028Fe292360q@802992e293360q@802:93e2943;02;94e2@30q95S;J80495DQS;39042<95e29697P578764:" #(#fn(str-find)
   "\n\n" #fn(str-sub) "" #fn(str) "\n\n    " #fn(append) defstruct :type :named :constructor
   :conc-name :predicate) fmt) sym-set-doc #fn(append) :doc-fmt #fn(nconc) begin def s and equal?
-  typeof quote struct or not eq? aref = length %struct% #fn(copy-list) foldr #fn("n2202105201PP:" #(#fn(sym)
+  type-of quote struct or not eq? aref = length %struct% #fn(copy-list) foldr #fn("n2202105201PP:" #(#fn(sym)
   ":")) putprop constructor list map-int #fn("n1A<70F05251709205221938652943<0r20i2KM@30022872324Ie2e3953?0259523e2e2@30q262724e2282396360K@30E88Me3792:85523O02;2<2=2>86e22?2>97e22@e6e2@G02A2396360K@30E88M24e4e4e4:" #(list-ref
   #fn(sym) def s v assert if void? aref member :read-only error str "slot " quote " in struct " " is :read-only"
   aset!))))  bcode:ctable #fn("n1200Ke3:" #(aref))  with-output-to #fn("z12021e1220e2e1e12315163:" #(#fn(nconc)
@@ -132,7 +132,7 @@
             arg-counts #table(bound? 1  sym? 1  car 1  cons 2  cadr 1  nan? 1  for 3  fixnum? 1  cdr 1  atom? 1  div0 2  vec? 1  equal? 2  eqv? 2  compare 2  not 1  set-cdr! 2  num? 1  fn? 1  eq? 2  builtin? 1  cons? 1  set-car! 2)
             argc-error #fn("n2702102211Kl237023@402465:" #(error "compile error: " " expects " " argument."
                                                            " arguments.") argc-error)
-            arr? #fn("n10];JF042005185B;390485<21Q:" #(#fn(typeof) arr) arr?) assoc
+            arr? #fn("n10];JF042005185B;390485<21Q:" #(#fn(type-of) arr) arr?) assoc
             #fn("n2701510d3501<:13:07101=62:q:" #(caar assoc) assoc) assv #fn("n2701510c3501<:13:07101=62:q:" #(caar
   assv) assv)
             bcode:indexfor #fn("n20KG0r2G20861523:02186162:2286187534870r287KMp4:" #(#fn(has?)
@@ -387,7 +387,7 @@
             print #fn("z02071062:" #(#fn(for-each) write) print) print-exception
             #fn("n170051;3N04700<51;3C04217205151;35040<853700=@30086;3?0486<R;360486<87;360486=853O0732485<512585T257685512756@30q48728CQ0732988<2:2;88T51275547<88T51@61872=CH0732>88T2?5347<88<51@\x190872@C@0732A88<2B53@\x040872CCB0732D5147388f2@\xed0872EC?07F88<514I:@\xd90872GCB0732H5147388f2@\xc20872ICB0732J5147388f2@\xab0872KC>0732L88<52@\x980872MCR0732N88<513702O@402P5147<88<51@q0872QCB0732R5147388f2@Z0872SQ;J804872TQ3;07388f2@?0732U5147<865147V60:" #(list?
   #fn(io?) caar princ #fn(io-filename) ":" caddr ": " type-error "type error: expected " ", got "
-  #fn(typeof) print bounds-error "index " " out of bounds for " unbound-error "eval: variable " " has no value"
+  #fn(type-of) print bounds-error "index " " out of bounds for " unbound-error "eval: variable " " has no value"
   error "error: " load-error print-exception parse-error "parsing error: " arg-error "arguments error: "
   key-error "key not found: " const-error #fn(keyword?)
   "keywords are read-only: " "tried to modify a constant: " io-error "I/O error: " divide-error
@@ -437,7 +437,7 @@
             revappend #fn("n2701062:" #(reverse-) revappend) reverse
             #fn("n170q062:" #(reverse-) reverse) reverse! #fn("n170q062:" #(reverse!-) reverse!)
             reverse!- #fn("n2I1B3B041=101?04N4?1@\x1d/40:" #() reverse!-) reverse-
-            #fn("n21J400:701<0P1=62:" #(reverse-) reverse-) rune? #fn("n12005121Q:" #(#fn(typeof)
+            #fn("n21J400:701<0P1=62:" #(reverse-) reverse-) rune? #fn("n12005121Q:" #(#fn(type-of)
                                                                                       rune) rune?)
             self-evaluating? #fn("n120051S;3Z040H;36040RS;JK0421051;3A040R;3:04022051Q:" #(#fn(gensym?)
   #fn(const?) #fn(top-level-value)) self-evaluating?)
--- a/src/cvalues.c
+++ b/src/cvalues.c
@@ -645,7 +645,7 @@
 }
 
 sl_purefn
-BUILTIN("typeof", typeof)
+BUILTIN("type-of", type_of)
 {
 	sl_v v = args[0];
 	argcount(nargs, 1);
--- a/src/system.sl
+++ b/src/system.sl
@@ -404,11 +404,11 @@
       x0))
 
 (def (rune? x)
-  (eq? (typeof x) 'rune))
+  (eq? (type-of x) 'rune))
 
 (def (arr? x)
   (or (vec? x)
-      (let ((tx (typeof x)))
+      (let ((tx (type-of x)))
         (and (cons? tx) (eq? (car tx) 'arr)))))
 
 (def (closure? x)
@@ -1169,7 +1169,7 @@
    `(begin
       ; predicate
       ,(when is? `(def (,is? s)
-                    (and [equal? (typeof s) '(struct ,name)]
+                    (and [equal? (type-of s) '(struct ,name)]
                          [or (not ',named) (eq? (aref s 0) ',name)]
                          [= (length s) ,(+ (if named 1 0) (if isvec
                                                               (* 2 num-slots)
@@ -1462,7 +1462,7 @@
     (when loc
       (princ (io-filename (car loc)) ":" (cadr loc) ":" (caddr loc) ": "))
     (cond ((eq? k 'type-error)
-           (princ "type error: expected " (car a) ", got " (typeof (cadr a)) ": ")
+           (princ "type error: expected " (car a) ", got " (type-of (cadr a)) ": ")
            (print (cadr a)))
 
           ((eq? k 'bounds-error)
--- a/test/unittest.sl
+++ b/test/unittest.sl
@@ -281,7 +281,7 @@
 (assert (equal? (keys1 :a 11) 12))
 
 ; cvalues and arrays
-(assert (equal? (typeof "") '(arr utf8)))
+(assert (equal? (type-of "") '(arr utf8)))
 (assert-fail (aref #(1) 3) bounds-error)
 (def iarr (arr 's64 32 16 8 7 1))
 (assert (equal? (aref iarr 0) 32))