fixed the tests with new args

This commit is contained in:
Felix Brendel
2019-09-21 01:24:15 +02:00
parent 5f90f2877f
commit 47b33f2f3a
14 changed files with 1108 additions and 1439 deletions
+5 -6
View File
@@ -1,8 +1,8 @@
(define-syntax (define-class name-and-members :rest body)
(define-syntax (define-class name-and-members . body)
"Macro for creating simple classes."
(let ((name (first name-and-members))
(members (rest name-and-members)))
`(set-type
`(set-type!
(define
;; The function definition
(,(string->symbol (concat-strings "make-" (symbol->string name))) @members)
@@ -11,8 +11,8 @@
;; the body
@body
(let ,(zip members members)
(set-type
(lambda (:rest args)
(set-type!
(lambda args
"This is the docs for the handle"
(let ((op (eval (first args))))
(if (callable? op)
@@ -21,6 +21,5 @@
,(symbol->keyword name))))
:constructor)))
(define-syntax (-> obj meth :rest args)
(define-syntax (-> obj meth . args)
`(,obj ',meth @args))
+1 -3
View File
@@ -36,7 +36,6 @@ condition is false."
(define-syntax (let bindings . body)
(define (unzip lists)
(break)
(when lists
(define (iter lists l1 l2)
(define elem (first lists))
@@ -45,7 +44,6 @@ condition is false."
(pair (first elem) l1)
(pair (first (rest elem)) l2))
(list l1 l2))))
(iter lists () ()))
(define unzipped (unzip bindings))
@@ -152,7 +150,7 @@ ithe sequence as arguemens."
(concat-strings module-prefix
(symbol->string orig-export-name)))))
`(define ,export-name
,(try (eval orig-export-name)
,(mytry (eval orig-export-name)
(error "The module does not contain" orig-export-name)))))
exports))))
+2 -2
View File
@@ -6,7 +6,7 @@
(define-syntax (n-times times action) :doc "Executes action times times." (define (repeat times elem) (unless (> 1 times) (pair elem (repeat (- times 1) elem)))) `(begin (unquote-splicing (repeat times action))))
(define-syntax (let bindings . body) (define (unzip lists) (break) (when lists (define (iter lists l1 l2) (define elem (first lists)) (if elem (iter (rest lists) (pair (first elem) l1) (pair (first (rest elem)) l2)) (list l1 l2)))) (iter lists () ())) (define unzipped (unzip bindings)) `((,lambda ,(first unzipped) (unquote-splicing body)) (unquote-splicing (first (rest unzipped)))))
(define-syntax (let bindings . body) (define (unzip lists) (when lists (define (iter lists l1 l2) (define elem (first lists)) (if elem (iter (rest lists) (pair (first elem) l1) (pair (first (rest elem)) l2)) (list l1 l2)))) (iter lists () ())) (define unzipped (unzip bindings)) `((,lambda ,(first unzipped) (unquote-splicing body)) (unquote-splicing (first (rest unzipped)))))
(define-syntax (cond . clauses) (define (rec clauses) (if (= nil clauses) nil (if (= (first (first clauses)) 'else) (begin (if (not (= (rest clauses) ())) (error "There are additional clauses after the else clause!") (pair 'begin (rest (first clauses))))) `(if ,(first (first clauses)) (begin (unquote-splicing (rest (first clauses)))) ,(rec (rest clauses)))))) (rec clauses))
@@ -20,7 +20,7 @@
(define-syntax (define-typed args . body) (define (get-arg-names args) (when args (pair (first args) (get-arg-names (rest (rest args)))))) (let ((name (first args)) (lambda-list (rest args)) (arg-names (get-arg-names (rest args)))) `(define (,name (unquote-splicing arg-names)) (assert-types= (unquote-splicing lambda-list)) (unquote-splicing body))))
(define-syntax (define-module module-name :exports . body) (let ((module-prefix (concat-strings (symbol->string module-name) "::"))) (eval `(begin (unquote-splicing body))) (pair 'begin (map (lambda (orig-export-name) (let ((export-name (string->symbol (concat-strings module-prefix (symbol->string orig-export-name))))) `(define ,export-name ,(try (eval orig-export-name) (error "The module does not contain" orig-export-name))))) exports))))
(define-syntax (define-module module-name :exports . body) (let ((module-prefix (concat-strings (symbol->string module-name) "::"))) (eval `(begin (unquote-splicing body))) (pair 'begin (map (lambda (orig-export-name) (let ((export-name (string->symbol (concat-strings module-prefix (symbol->string orig-export-name))))) `(define ,export-name ,(mytry (eval orig-export-name) (error "The module does not contain" orig-export-name))))) exports))))
(define (null? x) :doc "Checks if the argument is =nil=." (= x ()))
+3 -4
View File
@@ -5,8 +5,8 @@
(define key-not-found-index -1)
(define (make :rest vals)
(set-type
(define (make . vals)
(set-type!
(if vals
(list vals)
'(()))
@@ -27,7 +27,6 @@
(define (insert! set value)
(unless (contains? set value)
(set! set (pair (pair value (first set)) ()))
(set-type set :set))
(set-type! set :set))
set)
)
+2 -2
View File
@@ -1,7 +1,7 @@
((lambda (:keys k1 :defaults-to (+ 1 2 3))
((lambda ((:k1 (+ 1 2 3)))
(assert (= k1 6))))
((lambda (:keys k1 :defaults-to ())
((lambda ((:k1 ()))
(when k1
(assert ()))
(assert (= k1 ()))))
+1 -1
View File
@@ -32,7 +32,7 @@
;; key arguments
(define (make-key-counter)
((lambda (:keys var)
((lambda (:var)
(lambda ()
(mutate var (+ 1 var))
var))
+1 -1
View File
@@ -26,7 +26,7 @@
(define (g) (define x 0) (lambda () (define temp x) (mutate x (+ x 1)) temp))
(define (make-key-counter) ((lambda (:keys var) (lambda () (mutate var (+ 1 var)) var)) :var 0))
(define (make-key-counter) ((lambda (:var) (lambda () (mutate var (+ 1 var)) var)) :var 0))
(define key-counter1 (make-key-counter))
+92 -412
View File
@@ -1,7 +1,14 @@
\hrule
* =file_name=
- defined in :: =generate-docs.slime:5:44=
- type :: =:string=
- value :: ="../manual/built-in-docs.org"=
- docu :: none
\hrule
* ===
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:166:0=
- defined in :: =src/./built_ins.cpp:159:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -10,7 +17,7 @@ Takes 0 or more arguments and returns =t= if all arguments are equal and =()= ot
\hrule
* =>=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:182:0=
- defined in :: =src/./built_ins.cpp:175:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -19,7 +26,7 @@ TODO
\hrule
* =>==
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:199:0=
- defined in :: =src/./built_ins.cpp:189:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -28,7 +35,7 @@ TODO
\hrule
* =<=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:216:0=
- defined in :: =src/./built_ins.cpp:203:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -37,7 +44,7 @@ TODO
\hrule
* =<==
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:235:0=
- defined in :: =src/./built_ins.cpp:217:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -46,7 +53,7 @@ TODO
\hrule
* =+=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:252:0=
- defined in :: =src/./built_ins.cpp:231:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -55,7 +62,7 @@ TODO
\hrule
* =-=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:264:0=
- defined in :: =src/./built_ins.cpp:243:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -64,7 +71,7 @@ TODO
\hrule
* =*=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:286:0=
- defined in :: =src/./built_ins.cpp:264:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -73,7 +80,7 @@ TODO
\hrule
* =/=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:306:0=
- defined in :: =src/./built_ins.cpp:281:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -82,7 +89,7 @@ TODO
\hrule
* =**=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:326:0=
- defined in :: =src/./built_ins.cpp:300:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -91,7 +98,7 @@ TODO
\hrule
* =%=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:341:0=
- defined in :: =src/./built_ins.cpp:307:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -100,7 +107,16 @@ TODO
\hrule
* =assert=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:356:0=
- defined in :: =src/./built_ins.cpp:314:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
TODO
#+END:
\hrule
* =define-syntax=
- defined in :: =src/./built_ins.cpp:323:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -109,7 +125,7 @@ TODO
\hrule
* =define=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:367:0=
- defined in :: =src/./built_ins.cpp:369:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -118,7 +134,7 @@ TODO
\hrule
* =mutate=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:429:0=
- defined in :: =src/./built_ins.cpp:425:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -127,7 +143,7 @@ TODO
\hrule
* =vector-length=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:454:0=
- defined in :: =src/./built_ins.cpp:447:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -136,7 +152,7 @@ TODO
\hrule
* =vector-ref=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:462:0=
- defined in :: =src/./built_ins.cpp:452:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -145,7 +161,7 @@ TODO
\hrule
* =vector-set!=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:479:0=
- defined in :: =src/./built_ins.cpp:465:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -154,7 +170,7 @@ TODO
\hrule
* =set!=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:499:0=
- defined in :: =src/./built_ins.cpp:480:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -163,7 +179,7 @@ TODO
\hrule
* =set-car!=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:521:0=
- defined in :: =src/./built_ins.cpp:500:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -172,7 +188,7 @@ TODO
\hrule
* =set-cdr!=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:532:0=
- defined in :: =src/./built_ins.cpp:508:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -181,7 +197,7 @@ TODO
\hrule
* =if=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:543:0=
- defined in :: =src/./built_ins.cpp:516:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -190,7 +206,7 @@ TODO
\hrule
* =quote=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:563:0=
- defined in :: =src/./built_ins.cpp:530:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -199,7 +215,7 @@ TODO
\hrule
* =quasiquote=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:568:0=
- defined in :: =src/./built_ins.cpp:534:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -208,7 +224,7 @@ TODO
\hrule
* =and=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:665:0=
- defined in :: =src/./built_ins.cpp:631:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -217,7 +233,7 @@ TODO
\hrule
* =or=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:676:0=
- defined in :: =src/./built_ins.cpp:643:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -226,16 +242,7 @@ TODO
\hrule
* =not=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:687:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
TODO
#+END:
\hrule
* =while=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:697:0=
- defined in :: =src/./built_ins.cpp:655:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -244,7 +251,7 @@ TODO
\hrule
* =lambda=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:775:0=
- defined in :: =src/./built_ins.cpp:689:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -253,7 +260,7 @@ TODO
\hrule
* =special-lambda=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:787:0=
- defined in :: =src/./built_ins.cpp:705:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -262,7 +269,7 @@ TODO
\hrule
* =eval=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:795:0=
- defined in :: =src/./built_ins.cpp:721:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -271,7 +278,7 @@ TODO
\hrule
* =begin=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:807:0=
- defined in :: =src/./built_ins.cpp:731:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -280,7 +287,7 @@ TODO
\hrule
* =list=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:823:0=
- defined in :: =src/./built_ins.cpp:743:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -289,7 +296,7 @@ TODO
\hrule
* =vector=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:827:0=
- defined in :: =src/./built_ins.cpp:747:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -298,7 +305,7 @@ TODO
\hrule
* =pair=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:833:0=
- defined in :: =src/./built_ins.cpp:754:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -307,7 +314,7 @@ TODO
\hrule
* =first=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:843:0=
- defined in :: =src/./built_ins.cpp:761:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -316,25 +323,25 @@ TODO
\hrule
* =rest=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:854:0=
- defined in :: =src/./built_ins.cpp:768:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
TODO
#+END:
\hrule
* =set-type=
* =set-type!=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:865:0=
- defined in :: =src/./built_ins.cpp:775:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
TODO
#+END:
\hrule
* =delete-type=
* =delete-type!=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:877:0=
- defined in :: =src/./built_ins.cpp:781:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -343,7 +350,16 @@ TODO
\hrule
* =type=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:884:0=
- defined in :: =src/./built_ins.cpp:786:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
TODO
#+END:
\hrule
* =mem-reset=
- defined in :: =src/./built_ins.cpp:819:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -352,7 +368,7 @@ TODO
\hrule
* =info=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:918:0=
- defined in :: =src/./built_ins.cpp:828:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -361,7 +377,7 @@ TODO
\hrule
* =show=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:999:0=
- defined in :: =src/./built_ins.cpp:899:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -370,7 +386,7 @@ TODO
\hrule
* =addr-of=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1011:0=
- defined in :: =src/./built_ins.cpp:911:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -379,7 +395,7 @@ TODO
\hrule
* =generate-docs=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1017:0=
- defined in :: =src/./built_ins.cpp:916:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -388,7 +404,7 @@ TODO
\hrule
* =print=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1026:0=
- defined in :: =src/./built_ins.cpp:922:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -397,7 +413,7 @@ TODO
\hrule
* =read=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1034:0=
- defined in :: =src/./built_ins.cpp:937:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -406,7 +422,7 @@ TODO
\hrule
* =exit=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1051:0=
- defined in :: =src/./built_ins.cpp:949:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -415,7 +431,7 @@ TODO
\hrule
* =break=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1062:0=
- defined in :: =src/./built_ins.cpp:954:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -424,16 +440,7 @@ TODO
\hrule
* =memstat=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1067:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
TODO
#+END:
\hrule
* =try=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1071:0=
- defined in :: =src/./built_ins.cpp:960:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -442,7 +449,7 @@ TODO
\hrule
* =load=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1086:0=
- defined in :: =src/./built_ins.cpp:979:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -451,7 +458,7 @@ TODO
\hrule
* =import=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1097:0=
- defined in :: =src/./built_ins.cpp:989:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -460,16 +467,7 @@ TODO
\hrule
* =copy=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1108:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
TODO
#+END:
\hrule
* =error=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1116:0=
- defined in :: =src/./built_ins.cpp:1000:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -478,7 +476,7 @@ TODO
\hrule
* =symbol->keyword=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1123:0=
- defined in :: =src/./built_ins.cpp:1013:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -487,7 +485,7 @@ TODO
\hrule
* =string->symbol=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1132:0=
- defined in :: =src/./built_ins.cpp:1018:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -496,7 +494,7 @@ TODO
\hrule
* =symbol->string=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1144:0=
- defined in :: =src/./built_ins.cpp:1027:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -505,7 +503,7 @@ TODO
\hrule
* =concat-strings=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1153:0=
- defined in :: =src/./built_ins.cpp:1034:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -514,7 +512,6 @@ TODO
\hrule
* =pe=
- defined in :: =pre.slime:4:40=
- type :: =:macro=
- arguments :: :
- postitional :: =expr=
@@ -522,7 +519,6 @@ TODO
\hrule
* =when=
- defined in :: =pre.slime:23:41=
- type :: =:macro=
- arguments :: :
- postitional :: =condition=:
@@ -547,7 +543,6 @@ condition is true.
\hrule
* =unless=
- defined in :: =pre.slime:30:41=
- type :: =:macro=
- arguments :: :
- postitional :: =condition=:
@@ -560,7 +555,6 @@ condition is false.
\hrule
* =n-times=
- defined in :: =pre.slime:37:35=
- type :: =:macro=
- arguments :: :
- postitional :: =times=, =action=
@@ -571,7 +565,6 @@ Executes action times times.
\hrule
* =let=
- defined in :: =pre.slime:54:64=
- type :: =:macro=
- arguments :: :
- postitional :: =bindings=:
@@ -580,7 +573,6 @@ Executes action times times.
\hrule
* =cond=
- defined in :: =pre.slime:68:17=
- type :: =:macro=
- arguments :: :
- rest :: =clauses=
@@ -588,7 +580,6 @@ Executes action times times.
\hrule
* =case=
- defined in :: =pre.slime:83:17=
- type :: =:macro=
- arguments :: :
- postitional :: =var=:
@@ -597,7 +588,6 @@ Executes action times times.
\hrule
* =define-special=
- defined in :: =pre.slime:86:81=
- type :: =:macro=
- arguments :: :
- postitional :: =name-and-args=:
@@ -606,7 +596,6 @@ Executes action times times.
\hrule
* =construct-list=
- defined in :: =pre.slime:127:14=
- type :: =:macro=
- arguments :: :
- rest :: =body=
@@ -633,7 +622,6 @@ Executes action times times.
\hrule
* =apply=
- defined in :: =pre.slime:132:28=
- type :: =:macro=
- arguments :: :
- postitional :: =fun=, =seq=
@@ -645,7 +633,6 @@ ithe sequence as arguemens.
\hrule
* =define-typed=
- defined in :: =pre.slime:144:16=
- type :: =:macro=
- arguments :: :
- postitional :: =args=:
@@ -654,7 +641,6 @@ ithe sequence as arguemens.
\hrule
* =define-module=
- defined in :: =pre.slime:158:27=
- type :: =:macro=
- arguments :: :
- postitional :: =module-name=:
@@ -804,7 +790,7 @@ Returns the last pair in the sqeuence.
{{{example_start}}}
(define a (list 1 2 3 4))
(printf (end a))
(print (end a))
{{{example_end}}}
#+END:
@@ -820,7 +806,7 @@ Returns the (first) of the last (pair) of the given sequence.
{{{example_start}}}
(define a (list 1 2 3 4))
(printf (last a))
(print (last a))
{{{example_end}}}
#+END:
@@ -916,15 +902,15 @@ Subtracts one from the argument.
- keyword :: =from= =(0)=, =to=
- docu ::
#+BEGIN:
Returns a sequence of numbers starting with the number defined by the
key =from= and ends with the number defined in =to=.
Returns a sequence of numbers starting with the number defined
by the key =from= and ends with the number defined in =to=.
#+END:
\hrule
* =range-while=
- type :: =:lambda=
- arguments :: :
- keyword :: =from= =(0)=, =to=
- keyword :: =from= =(0)=
- docu ::
#+BEGIN:
Returns a sequence of numbers starting with the number defined
@@ -950,10 +936,10 @@ elemens as argument to that function.
- postitional :: =fun=, =seq=
- docu ::
#+BEGIN:
Takes a function and a sequence as arguments and applies the
function to the argument sequence. This only works correctly if the
given function accepts a variable amount of parameters. If your
funciton is limited to two arguments, use [[=reduce-binary=]]
Takes a function and a sequence as arguments and applies the
function to the argument sequence. This only works correctly if the
given function accepts a variable amount of parameters. If your
funciton is limited to two arguments, use [[=reduce-binary=]]
instead.
#+END:
\hrule
@@ -964,9 +950,9 @@ instead.
- postitional :: =fun=, =seq=
- docu ::
#+BEGIN:
Takes a function and a sequence as arguments and applies the
Takes a function and a sequence as arguments and applies the
function to the argument sequence. reduce-binary applies the arguments
*pair-wise* which means it works with binary functions as compared to
*pair-wise* which means it works with binary functions as compared to
[[=reduce=]].
#+END:
\hrule
@@ -1003,309 +989,3 @@ added to a list, which in the end is returned.
- arguments :: :
- postitional :: =seq=
- docu :: none
\hrule
* =printf=
- type :: =:lambda=
- arguments :: :
- keyword :: =sep= =(" ")=, =end= =("\n")=:
- rest :: =args=
- docu ::
#+BEGIN:
A wrapper for the built-in function [[=print=]] that accepts a
variable number of arguments and also provides keywords for specifying
the printed separators (=sep=) between the arguments and what should
be printed after the last argument (=end=).
#+END:
\hrule
* =key-not-found-index=
- defined in :: =alist.slime:28:31=
- type :: =:number=
- value :: =-1=
- docu :: none
\hrule
* =make-alist=
- type :: =:lambda=
- arguments :: none.
- docu :: none
\hrule
* =make-plist=
- type :: =:lambda=
- arguments :: none.
- docu :: none
\hrule
* =pprint-alist=
- type :: =:lambda=
- arguments :: :
- postitional :: =alist=
- docu :: none
\hrule
* =pprint-plist=
- type :: =:lambda=
- arguments :: :
- postitional :: =plist=
- docu :: none
\hrule
* =alist-get=
- type :: =:lambda=
- arguments :: :
- postitional :: =alist=, =key=
- docu :: none
\hrule
* =alist-find=
- type :: =:lambda=
- arguments :: :
- postitional :: =alist=, =key=
- docu :: none
\hrule
* =alist-key-exists?=
- type :: =:lambda=
- arguments :: :
- postitional :: =alist=, =key=
- docu :: none
\hrule
* =alist-remove!=
- type :: =:lambda=
- arguments :: :
- postitional :: =alist=, =key=
- docu :: none
\hrule
* =alist-set!=
- type :: =:lambda=
- arguments :: :
- postitional :: =alist=, =key=, =value=
- docu :: none
\hrule
* =alist-set-overwrite!=
- type :: =:lambda=
- arguments :: :
- postitional :: =alist=, =key=, =value=
- docu :: none
\hrule
* =plist-get=
- type :: =:lambda=
- arguments :: :
- postitional :: =plist=, =prop=
- docu :: none
\hrule
* =plist-set!=
- type :: =:lambda=
- arguments :: :
- postitional :: =plist=, =prop=, =value=
- docu :: none
\hrule
* =plist-set-overwrite!=
- type :: =:lambda=
- arguments :: :
- postitional :: =plist=, =prop=, =value=
- docu :: none
\hrule
* =plist-find=
- type :: =:lambda=
- arguments :: :
- postitional :: =plist=, =prop=
- docu :: none
\hrule
* =plist-prop-exists?=
- type :: =:lambda=
- arguments :: :
- postitional :: =plist=, =prop=
- docu :: none
\hrule
* =plist-remove!=
- type :: =:lambda=
- arguments :: :
- postitional :: =plist=, =prop=
- docu :: none
\hrule
* =cons=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:833:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
TODO
#+END:
\hrule
* =car=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:843:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
TODO
#+END:
\hrule
* =cdr=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:854:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
TODO
#+END:
\hrule
* =caar=
- type :: =:lambda=
- arguments :: :
- postitional :: =seq=
- docu :: none
\hrule
* =cddr=
- type :: =:lambda=
- arguments :: :
- postitional :: =seq=
- docu :: none
\hrule
* =cadr=
- type :: =:lambda=
- arguments :: :
- postitional :: =seq=
- docu :: none
\hrule
* =cdar=
- type :: =:lambda=
- arguments :: :
- postitional :: =seq=
- docu :: none
\hrule
* =caaar=
- type :: =:lambda=
- arguments :: :
- postitional :: =seq=
- docu :: none
\hrule
* =caadr=
- type :: =:lambda=
- arguments :: :
- postitional :: =seq=
- docu :: none
\hrule
* =cadar=
- type :: =:lambda=
- arguments :: :
- postitional :: =seq=
- docu :: none
\hrule
* =caddr=
- type :: =:lambda=
- arguments :: :
- postitional :: =seq=
- docu :: none
\hrule
* =cdaar=
- type :: =:lambda=
- arguments :: :
- postitional :: =seq=
- docu :: none
\hrule
* =cdadr=
- type :: =:lambda=
- arguments :: :
- postitional :: =seq=
- docu :: none
\hrule
* =cddar=
- type :: =:lambda=
- arguments :: :
- postitional :: =seq=
- docu :: none
\hrule
* =cdddr=
- type :: =:lambda=
- arguments :: :
- postitional :: =seq=
- docu :: none
\hrule
* =define-class=
- defined in :: =oo.slime:22:22=
- type :: =:macro=
- arguments :: :
- postitional :: =name-and-members=:
- rest :: =body=
- docu ::
#+BEGIN:
Macro for creating simple classes.
#+END:
\hrule
* =->=
- defined in :: =oo.slime:25:24=
- type :: =:macro=
- arguments :: :
- postitional :: =obj=, =meth=:
- rest :: =args=
- docu :: none
\hrule
* =math::pi=
- defined in :: =pre.slime:338:12=
- type :: =:number=
- value :: =3.141593=
- docu ::
#+BEGIN:
Tha famous circle constant.
#+END:
\hrule
* =math::abs=
- defined in :: =pre.slime:338:12=
- type :: =:lambda=
- arguments :: :
- postitional :: =x=
- docu ::
#+BEGIN:
Accepts one argument and returns the absoulte value of it
#+END:
\hrule
* =math::sqrt=
- defined in :: =pre.slime:338:12=
- type :: =:lambda=
- arguments :: :
- postitional :: =x=
- docu ::
#+BEGIN:
Accepts one argument and returns the square root of it
#+END:
\hrule
* =math::make-vector3=
- defined in :: =pre.slime:338:12=
- type :: =:constructor=
- arguments :: :
- postitional :: =x=, =y=, =z=
- docu ::
#+BEGIN:
This is the handle to an object of the class vector3
#+END:
+29 -39
View File
@@ -1,5 +1,5 @@
inline proc maybe_wrap_body_in_begin(Lisp_Object* body) -> Lisp_Object* {
static Lisp_Object* begin_symbol = Memory::get_or_create_lisp_object_symbol("begin");
Lisp_Object* begin_symbol = Memory::get_or_create_lisp_object_symbol("begin");
if (body->value.pair.rest == Memory::nil)
return body->value.pair.first;
else
@@ -101,11 +101,11 @@ proc built_in_import(String* file_name) -> Lisp_Object* {
}
proc load_built_ins_into_environment() -> void {
static String* file_name_built_ins = Memory::create_string(__FILE__);
String* file_name_built_ins = Memory::create_string(__FILE__);
#define fetch1(var) \
static Lisp_Object* var##_symbol = Memory::get_or_create_lisp_object_symbol(#var); \
Lisp_Object* var##_symbol = Memory::get_or_create_lisp_object_symbol(#var); \
Lisp_Object* var = lookup_symbol(var##_symbol, get_current_environment()); \
if (Globals::error) printf("in %s:%d\n", __FILE__, __LINE__)
@@ -128,12 +128,12 @@ proc load_built_ins_into_environment() -> void {
// parser relys on being able to temporaily put in markers
// in the code
#define _define_helper(def, docs, special) \
static Lisp_Object* label(params,__LINE__) = Parser::parse_single_expression( \
auto label(params,__LINE__) = Parser::parse_single_expression( \
Memory::get_c_str(Memory::create_string(#def)) \
); \
assert_type(label(params,__LINE__), Lisp_Object_Type::Pair); \
assert_type(label(params,__LINE__)->value.pair.first, Lisp_Object_Type::Symbol); \
static auto label(sym,__LINE__) = label(params,__LINE__)->value.pair.first; \
auto label(sym,__LINE__) = label(params,__LINE__)->value.pair.first; \
auto label(sfun,__LINE__) = Memory::create_lisp_object_cfunction(special); \
/*NOTE(Felix): for evaluating default args*/ \
push_environment(get_root_environment()); \
@@ -481,13 +481,13 @@ proc load_built_ins_into_environment() -> void {
fetch(sym, val);
try assert_type(sym, Lisp_Object_Type::Symbol);
Environment* target_env;
in_caller_env {
val = eval_expr(val);
target_env = find_binding_environment(sym->value.symbol.identifier, get_current_environment());
try assert(target_env);
}
Environment* target_env = find_binding_environment(sym->value.symbol.identifier, get_current_environment());
try assert(target_env);
push_environment(target_env);
{
@@ -728,13 +728,14 @@ proc load_built_ins_into_environment() -> void {
return result;
};
define((begin . args), "TODO") {
define_special((begin . args), "TODO") {
fetch(args);
Lisp_Object* result = Memory::nil;
for_lisp_list(args) {
try result = eval_expr(it);
in_caller_env {
for_lisp_list(args) {
try result = eval_expr(it);
}
}
return result;
};
define((list . args), "TODO") {
@@ -813,6 +814,10 @@ proc load_built_ins_into_environment() -> void {
}
return Memory::get_or_create_lisp_object_keyword("unknown");
};
define((mem-reset), "TODO") {
Memory::reset();
return Memory::nil;
};
// NOTE(Felix): we need to define_special because the docstring is
// attached to the symbol. Because some object are singletons
// (symbols, keyowrds, nil, t) we dont want to store docs on the
@@ -887,20 +892,6 @@ proc load_built_ins_into_environment() -> void {
printf("}\n");
}
// }
// // TODO(Felix): Maybe don't compare strings here?? Wtf
// if (Memory::get_type(type) == Lisp_Object_Type::Keyword &&
// (string_equal(type->value.symbol.identifier, "lambda") ||
// string_equal(type->value.symbol.identifier, "special-lambda") ||
// string_equal(type->value.symbol.identifier, "macro")))
// {
// Lisp_Object* fun = eval_expr(n);
// if (fun->docstring)
// printf("Docstring:\n==========\n%s\n\n", Memory::get_c_str(fun->docstring));
// else
// printf("No docstring avaliable\n");
return Memory::nil;
};
define((show n), "TODO") {
@@ -968,21 +959,20 @@ proc load_built_ins_into_environment() -> void {
Memory::print_status();
return Memory::nil;
};
// // defun("try", "TODO", __LINE__, cLambda {
// // try arguments_length = list_length(arguments);
// // try assert_arguments_length(2, arguments_length);
define_special((mytry try_part catch_part), "TODO") {
fetch(try_part, catch_part);
// // Lisp_Object* try_part = arguments->value.pair.first;
// // Lisp_Object* catch_part = arguments->value.pair.rest->value.pair.first;
// // Lisp_Object* result;
Lisp_Object* result;
// // result = eval_expr(try_part);
// // if (Globals::error) {
// // delete_error();
// // try result = eval_expr(catch_part);
// // }
// // return result;
// // });
in_caller_env {
result = eval_expr(try_part);
if (Globals::error) {
delete_error();
try result = eval_expr(catch_part);
}
}
return result;
};
define((load file), "TODO") {
fetch(file);
try assert_type(file, Lisp_Object_Type::String);
+3 -1
View File
@@ -84,7 +84,9 @@ inline proc get_current_environment() -> Environment* {
}
proc lookup_symbol(Lisp_Object* node, Environment* env) -> Lisp_Object* {
assert_type(node, Lisp_Object_Type::Symbol);
// print(node);
// printf("\n");
assert_type(node, Lisp_Object_Type::Symbol);
Lisp_Object* result = try_lookup_symbol(node, env);
+1 -1
View File
@@ -16,7 +16,7 @@ proc create_error(const char* c_file_name, int c_file_line, Lisp_Object* type, S
delete_error();
if (Globals::breaking_on_errors) {
debug_break();
// debug_break();
}
// visualize_lisp_machine();
+1
View File
@@ -321,6 +321,7 @@ proc create_arguments_from_lambda_list_and_inject(Lisp_Object* arguments, Lisp_O
create_parsing_error("Default args must be a list of 2.");
}
auto value = arguments->value.pair.first->value.pair.rest->value.pair.first;
value = eval_expr(value);
if (arguments->value.pair.first->value.pair.rest->value.pair.rest != Memory::nil) {
create_parsing_error("Default args must be a list of 2.");
}
+1 -1
View File
@@ -4,7 +4,7 @@ int main(int argc, char* argv[]) {
if (argc > 1) {
if (Slime::string_equal(argv[1], "--run-tests")) {
int res = Slime::run_all_tests();
Slime::interprete_file((char*)"generate-docs.slime");
// Slime::interprete_file((char*)"generate-docs.slime");
return res ? 0 : 1;
}