Pārlūkot izejas kodu

alists and plists now

master
FelixBrendel pirms 6 gadiem
vecāks
revīzija
e0aaf351c5
14 mainītis faili ar 646 papildinājumiem un 106 dzēšanām
  1. +2
    -1
      .gitignore
  2. +94
    -3
      bin/alist.slime
  3. +1
    -0
      bin/generate-docs.slime
  4. +71
    -17
      bin/pre.slime
  5. +20
    -10
      bin/pre.slime.expanded
  6. +54
    -1
      bin/tests/alists.slime
  7. +37
    -0
      bin/tests/case_and_cond.slime
  8. +6
    -1
      build.bat
  9. +348
    -64
      manual/built-in-docs.org
  10. +1
    -1
      manual/manual.org
  11. +3
    -5
      src/built_ins.cpp
  12. +4
    -2
      src/eval.cpp
  13. +1
    -0
      src/testing.cpp
  14. +4
    -1
      todo.org

+ 2
- 1
.gitignore Parādīt failu

@@ -15,4 +15,5 @@ todo.html
*.expanded
/bin/vgcore.*
/manual/manual.pdf
/manual/manual.tex
/manual/manual.tex
*.out

+ 94
- 3
bin/alist.slime Parādīt failu

@@ -13,10 +13,29 @@
;; key1 key2
;;
;; '(((key1 . value1) (key2 . value2)))

;; plist:
;; [ |/]
;; |
;; V
;; [ | ]------------->[ | ]-------------> ...
;; | |
;; V V
;; :key1 value1
;;
;; '((:key1 value1 :key2 value2))

(define key-not-found-index -1)

(define (make-alist)
'(()))
(set-type
'(())
:alist))

(define (make-plist)
(set-type
'(())
:plist))

(define (pprint-alist alist)
(let ((associations (first alist)))
@@ -32,6 +51,19 @@
(pprint-intern associations))
(print ")\n")))

(define (pprint-plist plist)
(let ((props (first plist)))
(define (pprint-intern props)
(when props
(printf " "
(car props) "->"
(cadr props))
(pprint-intern (cddr props))))
(print "(")
(when props
(print "\n")
(pprint-intern props))
(print ")\n")))

(define (alist-get alist key)
(let ((associations (first alist)))
@@ -76,7 +108,8 @@

(cond ((= index key-not-found-index) (error "key to remove was not found"))
((= index 0) (mutate alist (pair (cdar alist) ())))
(else (alist-remove!-internal alist index)))))
(else (alist-remove!-internal alist index))))
alist)


(define (alist-set! alist key value)
@@ -93,4 +126,62 @@
((null? associations) (alist-set! alist key value))
(else (alist-set-overwrite-intern
(rest associations) key value))))
(alist-set-overwrite-intern associations key value)))
(alist-set-overwrite-intern associations key value))
alist)


(define (plist-get plist prop)
(let ((props (first plist)))
(define (plist-get-intern props prop)
(cond ((null? props)
(error "property was not found in plist"))
((= (car props) prop)
(cadr props))
(else (plist-get-intern (cddr props) prop))))
(plist-get-intern props prop)))

(define (plist-set! plist prop value)
(mutate plist (pair (pair prop (pair value (first plist))) ())))

(define (plist-set-overwrite! plist prop value)
(let ((props (first plist)))
(define (plist-set-overwrite-intern props prop value)
(cond ((= (car props) prop)
(mutate (cdr props) (pair value (cddr props))))
((null? props) (plist-set! plist prop value))
(else (plist-set-overwrite-intern
(cddr props) prop value))))
(plist-set-overwrite-intern props prop value))
plist)

(define (plist-find plist prop)
(let ((props (first plist)))
(define (plist-find-intern props prop current-index)
(cond ((null? props) key-not-found-index)
((= (car props) prop) current-index)
(else (plist-find-intern (cddr props) prop
(+ 1 current-index)))))
(plist-find-intern props prop 0)))

(define (plist-prop-exists? plist prop)
(not (= (plist-find plist prop)
key-not-found-index)))

(define (plist-remove! plist prop)
(let ((index (plist-find plist prop)))
(define (plist-remove!-internal props index)
;; reminder: we only get called if we are not replacing the
;; first element in the alist
;; reminder2: we know that the key exists
(if (= index 1)
;; we want to remove the next one, so we set our
;; cdr to the next next one
(mutate (cdar props) (pair (cadar props) ;; xD nice meme dude!!!
(cdr (cdr (cdr (cdar props))))))
;; else cdr-recurse
(plist-remove!-internal (cddr props) (- index 1))))

(cond ((= index key-not-found-index) (error "prop to remove was not found"))
((= index 0) (mutate plist (pair (cddar plist) ())))
(else (plist-remove!-internal plist index))))
plist)

+ 1
- 0
bin/generate-docs.slime Parādīt failu

@@ -1,3 +1,4 @@
(import "alist.slime")
(import "oo.slime")
(import "math.slime")



+ 71
- 17
bin/pre.slime Parādīt failu

@@ -17,8 +17,8 @@ condition is true.
{{{example_end}}}
"
(if (= (rest body) ())
`(if ,condition @body)
`(if ,condition (begin @body))))
`(if ,condition @body nil)
`(if ,condition (begin @body) nil)))

(define-syntax (unless condition :rest body)
"Special form for when multiple actions should be done if a
@@ -57,13 +57,28 @@ condition is false."
nil
(if (= (first (first clauses)) 'else)
(begin
(if (not (= () (rest clauses)))
(if (not (= (rest clauses) ()))
(error "There are additional clauses after the else clause!")
(pair 'begin (rest (first clauses)))))
`(if ,(first (first clauses))
(begin @(rest (first clauses)))
,(rec (rest clauses))))))
(rec clauses))
(begin @(rest (first clauses)))
,(rec (rest clauses))))))
(rec clauses))


(define-syntax (case var :rest 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 (member? ,var ',(first (first clauses)))
(begin @(rest (first clauses)))
,(rec (rest clauses))))))
(rec clauses))

(define-syntax (define-special name-and-args :rest body)
`(define ,(first name-and-args) (special-lambda ,(rest name-and-args) @body)))
@@ -110,10 +125,24 @@ condition is false."
(rec body))

(define-syntax (apply fun seq)
"Applies the funciton to the sequence, as in calls the function with
"Applies the function to the sequence, as in calls the function with
ithe sequence as arguemens."
`(eval (pair ,fun ,seq)))

(define-syntax (define-typed args :rest 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 @arg-names)
(assert-types= @lambda-list)
@body)))

(define-typed (ttt a :number b :alist)
(printf a b))

(define-syntax (define-package name :rest body)
`(define ,(string->symbol (concat-strings (symbol->string name) "->"))
@@ -131,43 +160,62 @@ ithe sequence as arguemens."

(define (null? x)
"Checks if the argument is =nil=."
(= x nil))
(= x ()))

(define (type=? obj typ)
"Checks if the argument =obj= is of type =typ="
(= (type obj) typ))

(define (types=? :rest objs)
;; TODO make inner rec functoin to avoid evalutating every time
(if objs
(begin
(assert (keyword? (first (rest objs))))
(if (type=? (first objs) (first (rest objs)))
(apply types=? (rest (rest objs)))
()))
t))

(define (assert-types= :rest objs)
(break)
(unless (apply types=? objs)
(error "assert-types=: types do not match")))

(define (number? x)
"Checks if the argument is a number."
(= (type x) :number))
(type=? x :number))

(define (symbol? x)
"Checks if the argument is a symbol."
(= (type x) :symbol))
(type=? x :symbol))

(define (keyword? x)
"Checks if the argument is a keyword."
(= (type x) :keyword))
(type=? x :keyword))

(define (pair? x)
"Checks if the argument is a pair."
(= (type x) :pair))
(type=? x :pair))

(define (string? x)
"Checks if the argument is a string."
(= (type x) :string))
(type=? x :string))

(define (lambda? x)
"Checks if the argument is a function."
(= (type x) :lambda))
(type=? x :lambda))

(define (macro? x)
"Checks if the argument is a macro."
(= (type x) :macro))
(type=? x :macro))

(define (special-lambda? x)
"Checks if the argument is a special-lambda."
(= (type x) :dynamic-macro))
(type=? x :dynamic-macro))

(define (built-in-function? x)
"Checks if the argument is a built-in function."
(= (type x) :built-in-function))
(type=? x :built-in-function))

(define (callable? x)
(or (lambda? x)
@@ -229,6 +277,12 @@ with (pair elem nil)."
0
(+ 1 (length (rest seq)))))

(define (member? elem seq)
(when (pair? seq)
(if (= elem (first seq))
t
(member? elem (rest seq)))))

(define (sublist-starting-at-index seq index)
(cond ((< index 0)
(error "sublist-starting-at-index: index must be positive"))


+ 20
- 10
bin/pre.slime.expanded Parādīt failu

@@ -1,22 +1,30 @@
(define (null? x) "Checks if the argument is =nil=." (= x nil))
(define-typed (ttt a :number b :alist) (printf a b))

(define (number? x) "Checks if the argument is a number." (= (type x) :number))
(define (null? x) "Checks if the argument is =nil=." (= x ()))

(define (symbol? x) "Checks if the argument is a symbol." (= (type x) :symbol))
(define (type=? obj typ) "Checks if the argument =obj= is of type =typ=" (= (type obj) typ))

(define (keyword? x) "Checks if the argument is a keyword." (= (type x) :keyword))
(define (types=? :rest objs) (if objs (begin (assert (keyword? (first (rest objs)))) (if (type=? (first objs) (first (rest objs))) (apply types=? (rest (rest objs))) ())) t))

(define (pair? x) "Checks if the argument is a pair." (= (type x) :pair))
(define (assert-types= :rest objs) (break) (unless (apply types=? objs) (error "assert-types=: types do not match")))

(define (string? x) "Checks if the argument is a string." (= (type x) :string))
(define (number? x) "Checks if the argument is a number." (type=? x :number))

(define (lambda? x) "Checks if the argument is a function." (= (type x) :lambda))
(define (symbol? x) "Checks if the argument is a symbol." (type=? x :symbol))

(define (macro? x) "Checks if the argument is a macro." (= (type x) :macro))
(define (keyword? x) "Checks if the argument is a keyword." (type=? x :keyword))

(define (special-lambda? x) "Checks if the argument is a special-lambda." (= (type x) :dynamic-macro))
(define (pair? x) "Checks if the argument is a pair." (type=? x :pair))

(define (built-in-function? x) "Checks if the argument is a built-in function." (= (type x) :built-in-function))
(define (string? x) "Checks if the argument is a string." (type=? x :string))

(define (lambda? x) "Checks if the argument is a function." (type=? x :lambda))

(define (macro? x) "Checks if the argument is a macro." (type=? x :macro))

(define (special-lambda? x) "Checks if the argument is a special-lambda." (type=? x :dynamic-macro))

(define (built-in-function? x) "Checks if the argument is a built-in function." (type=? x :built-in-function))

(define (callable? x) (or (lambda? x) (special-lambda? x) (macro? x) (built-in-function? x)))

@@ -32,6 +40,8 @@

(define (length seq) "Returns the length of the given sequence." (if (null? seq) 0 (+ 1 (length (rest seq)))))

(define (member? elem seq) (when (pair? seq) (if (= elem (first seq)) t (member? elem (rest seq)))))

(define (sublist-starting-at-index seq index) (cond ((< index 0) (error "sublist-starting-at-index: index must be positive")) ((null? seq) ()) ((= 0 index) seq) (else (sublist-starting-at (rest seq) (- index 1)))))

(define (list-without-index seq index) (cond ((or (< index 0) (null? seq)) (error "list-remove-index!: index out of range")) ((= 0 index) (rest seq)) (else (pair (first seq) (list-without-index (rest seq) (- index 1))))))


+ 54
- 1
bin/tests/alists.slime Parādīt failu

@@ -1,7 +1,7 @@
(import "alist.slime")

(define a (make-alist))
;; a == ()
;; a == (())

(assert (= (first a) ()))

@@ -46,3 +46,56 @@
(assert (= (length (first a)) 2))
(assert (= (alist-get a 'key1) 'value1))
(assert (= (alist-get a 'key2) 'value2))


;; -------------
;;
;; PLISTS
;;
;; -------------

(define p (make-plist))
;; p == (())

(assert (= (first p) ()))

(plist-set! p :key1 'value1)
;; p == ((:key1 value1))

(assert (= (plist-get p :key1) 'value1))
(assert (plist-prop-exists? p :key1))
(assert (not (plist-prop-exists? p :key2)))

(plist-set! p :key2 'value2)
;; p == ((:key2 value2,
;; :key1 value1))

(assert (= (plist-get p :key2) 'value2))
(assert (plist-prop-exists? p :key2))
(assert (= (plist-find p :key2) 0))
(assert (= (plist-find p :key1) 1))
(assert (= (length (first p)) 4))

(plist-set! p :key1 'value3)
;; p == ((:key1 value3,
;; :key2 value2,
;; :key1 value1))

(assert (= (length (first p)) 6))
(assert (= (plist-get p :key1) 'value3))

(plist-set-overwrite! p :key1 'value4)
;; p == ((:key1 value4,
;; :key2 value2,
;; :key1 value1))

(assert (= (length (first p)) 6))
(assert (= (plist-get p :key1) 'value4))

(plist-remove! p :key1)
;; p == ((:key2 value2,
;; :key1 value1))

(assert (= (length (first p)) 4))
(assert (= (plist-get p :key1) 'value1))
(assert (= (plist-get p :key2) 'value2))

+ 37
- 0
bin/tests/case_and_cond.slime Parādīt failu

@@ -0,0 +1,37 @@
(define (test-cond x)
(cond ((< 0 x) +1)
((> 0 x) -1)
(else 0)))

(assert (= (test-cond 10) 1))
(assert (= (test-cond 1) 1))
(assert (= (test-cond 123) 1))

(assert (= (test-cond -10) -1))
(assert (= (test-cond -1) -1))
(assert (= (test-cond -123) -1))

(assert (= (test-cond 0) 0))
(assert (= (test-cond -0) 0))
(assert (= (test-cond +0) 0))


(define (test-case x)
(case x
((a b 3) 1)
((4 5 6) -1)
(else 'xD)))


(assert (= (test-case 'a) 1))
(assert (= (test-case 'b) 1))
(assert (= (test-case 3) 1))

(assert (= (test-case 4) -1))
(assert (= (test-case 5) -1))
(assert (= (test-case 6) -1))

(assert (= (test-case 0) 'xD))
(assert (= (test-case 1) 'xD))
(assert (= (test-case :asd) 'xD))


+ 6
- 1
build.bat Parādīt failu

@@ -14,9 +14,14 @@ call timecmd cl ../src/main.cpp /std:c++latest /Fe%exeName% /W3 /Zi /nologo /EHs
popd
if %errorlevel% == 0 (
echo.
echo Done
echo ---- Running Tests ----
echo.
call timecmd bin\slime.exe --run-tests
echo.
echo ---- Genderating Docs ----
echo.
call timecmd bin\slime generate-docs.slime

) else (
echo.
echo Fuckin' ell


+ 348
- 64
manual/built-in-docs.org Parādīt failu

@@ -1,7 +1,7 @@
\hrule
* ===

- defined in :: =src/./built_ins.cpp:158:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:158:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -10,7 +10,7 @@ Takes 0 or more arguments and returns =t= if all arguments are equal and =()= ot
\hrule
* =>=

- defined in :: =src/./built_ins.cpp:175:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:175:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -19,7 +19,7 @@ TODO
\hrule
* =>==

- defined in :: =src/./built_ins.cpp:193:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:193:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -28,7 +28,7 @@ TODO
\hrule
* =<=

- defined in :: =src/./built_ins.cpp:211:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:211:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -37,7 +37,7 @@ TODO
\hrule
* =<==

- defined in :: =src/./built_ins.cpp:231:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:231:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -46,7 +46,7 @@ TODO
\hrule
* =+=

- defined in :: =src/./built_ins.cpp:249:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:249:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -55,7 +55,7 @@ TODO
\hrule
* =-=

- defined in :: =src/./built_ins.cpp:262:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:262:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -64,7 +64,7 @@ TODO
\hrule
* =*=

- defined in :: =src/./built_ins.cpp:285:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:285:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -73,7 +73,7 @@ TODO
\hrule
* =/=

- defined in :: =src/./built_ins.cpp:306:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:306:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -82,7 +82,7 @@ TODO
\hrule
* =**=

- defined in :: =src/./built_ins.cpp:327:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:327:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -91,7 +91,7 @@ TODO
\hrule
* =%=

- defined in :: =src/./built_ins.cpp:343:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:343:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -100,7 +100,7 @@ TODO
\hrule
* =assert=

- defined in :: =src/./built_ins.cpp:359:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:359:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -109,7 +109,7 @@ TODO
\hrule
* =define=

- defined in :: =src/./built_ins.cpp:371:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:371:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -118,7 +118,7 @@ TODO
\hrule
* =mutate=

- defined in :: =src/./built_ins.cpp:433:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:433:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -127,7 +127,7 @@ TODO
\hrule
* =if=

- defined in :: =src/./built_ins.cpp:458:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:458:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -136,7 +136,7 @@ TODO
\hrule
* =quote=

- defined in :: =src/./built_ins.cpp:480:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:478:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -145,7 +145,7 @@ TODO
\hrule
* =quasiquote=

- defined in :: =src/./built_ins.cpp:485:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:483:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -154,7 +154,7 @@ TODO
\hrule
* =and=

- defined in :: =src/./built_ins.cpp:583:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:581:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -163,7 +163,7 @@ TODO
\hrule
* =or=

- defined in :: =src/./built_ins.cpp:594:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:592:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -172,7 +172,7 @@ TODO
\hrule
* =not=

- defined in :: =src/./built_ins.cpp:605:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:603:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -181,7 +181,7 @@ TODO
\hrule
* =while=

- defined in :: =src/./built_ins.cpp:615:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:613:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -190,7 +190,7 @@ TODO
\hrule
* =lambda=

- defined in :: =src/./built_ins.cpp:693:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:691:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -199,7 +199,7 @@ TODO
\hrule
* =special-lambda=

- defined in :: =src/./built_ins.cpp:705:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:703:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -208,7 +208,7 @@ TODO
\hrule
* =eval=

- defined in :: =src/./built_ins.cpp:713:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:711:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -217,7 +217,7 @@ TODO
\hrule
* =begin=

- defined in :: =src/./built_ins.cpp:725:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:723:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -226,7 +226,7 @@ TODO
\hrule
* =list=

- defined in :: =src/./built_ins.cpp:741:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:739:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -235,7 +235,7 @@ TODO
\hrule
* =pair=

- defined in :: =src/./built_ins.cpp:745:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:743:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -244,7 +244,7 @@ TODO
\hrule
* =first=

- defined in :: =src/./built_ins.cpp:755:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:753:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -253,7 +253,7 @@ TODO
\hrule
* =rest=

- defined in :: =src/./built_ins.cpp:766:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:764:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -262,7 +262,7 @@ TODO
\hrule
* =set-type=

- defined in :: =src/./built_ins.cpp:777:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:775:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -271,7 +271,7 @@ TODO
\hrule
* =delete-type=

- defined in :: =src/./built_ins.cpp:789:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:787:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -280,7 +280,7 @@ TODO
\hrule
* =type=

- defined in :: =src/./built_ins.cpp:796:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:794:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -289,7 +289,7 @@ TODO
\hrule
* =info=

- defined in :: =src/./built_ins.cpp:828:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:826:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -298,7 +298,7 @@ TODO
\hrule
* =show=

- defined in :: =src/./built_ins.cpp:910:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:908:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -307,7 +307,7 @@ TODO
\hrule
* =addr-of=

- defined in :: =src/./built_ins.cpp:922:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:920:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -316,7 +316,7 @@ TODO
\hrule
* =generate-docs=

- defined in :: =src/./built_ins.cpp:928:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:926:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -325,7 +325,7 @@ TODO
\hrule
* =print=

- defined in :: =src/./built_ins.cpp:937:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:935:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -334,7 +334,7 @@ TODO
\hrule
* =read=

- defined in :: =src/./built_ins.cpp:945:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:943:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -343,7 +343,7 @@ TODO
\hrule
* =exit=

- defined in :: =src/./built_ins.cpp:962:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:960:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -352,7 +352,7 @@ TODO
\hrule
* =break=

- defined in :: =src/./built_ins.cpp:973:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:971:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -361,7 +361,7 @@ TODO
\hrule
* =memstat=

- defined in :: =src/./built_ins.cpp:978:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:976:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -370,7 +370,7 @@ TODO
\hrule
* =try=

- defined in :: =src/./built_ins.cpp:982:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:980:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -379,7 +379,7 @@ TODO
\hrule
* =load=

- defined in :: =src/./built_ins.cpp:997:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:995:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -388,7 +388,7 @@ TODO
\hrule
* =import=

- defined in :: =src/./built_ins.cpp:1008:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1006:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -397,7 +397,7 @@ TODO
\hrule
* =copy=

- defined in :: =src/./built_ins.cpp:1019:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1017:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -406,7 +406,7 @@ TODO
\hrule
* =error=

- defined in :: =src/./built_ins.cpp:1027:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1025:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -415,7 +415,7 @@ TODO
\hrule
* =symbol->keyword=

- defined in :: =src/./built_ins.cpp:1034:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1032:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -424,7 +424,7 @@ TODO
\hrule
* =string->symbol=

- defined in :: =src/./built_ins.cpp:1043:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1041:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -433,7 +433,7 @@ TODO
\hrule
* =symbol->string=

- defined in :: =src/./built_ins.cpp:1055:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1053:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -442,7 +442,7 @@ TODO
\hrule
* =concat-strings=

- defined in :: =src/./built_ins.cpp:1064:0=
- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1062:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
@@ -459,7 +459,7 @@ TODO
\hrule
* =when=

- defined in :: =pre.slime:21:37=
- defined in :: =pre.slime:21:41=
- type :: =:macro=
- arguments :: :
- postitional :: =condition=:
@@ -517,15 +517,24 @@ Executes action times times.
\hrule
* =cond=

- defined in :: =pre.slime:66:19=
- defined in :: =pre.slime:66:17=
- type :: =:macro=
- arguments :: :
- rest :: =clauses=
- docu :: none
\hrule
* =case=

- defined in :: =pre.slime:81:17=
- type :: =:macro=
- arguments :: :
- postitional :: =var=:
- rest :: =clauses=
- docu :: none
\hrule
* =define-special=

- defined in :: =pre.slime:69:81=
- defined in :: =pre.slime:84:81=
- type :: =:macro=
- arguments :: :
- postitional :: =name-and-args=:
@@ -534,7 +543,7 @@ Executes action times times.
\hrule
* =construct-list=

- defined in :: =pre.slime:110:14=
- defined in :: =pre.slime:125:14=
- type :: =:macro=
- arguments :: :
- rest :: =body=
@@ -561,25 +570,41 @@ Executes action times times.
\hrule
* =apply=

- defined in :: =pre.slime:115:28=
- defined in :: =pre.slime:130:28=
- type :: =:macro=
- arguments :: :
- postitional :: =fun=, =seq=
- docu ::
#+BEGIN:
Applies the funciton to the sequence, as in calls the function with
Applies the function to the sequence, as in calls the function with
ithe sequence as arguemens.
#+END:
\hrule
* =define-typed=

- defined in :: =pre.slime:142:16=
- type :: =:macro=
- arguments :: :
- postitional :: =args=:
- rest :: =body=
- docu :: none
\hrule
* =define-package=

- defined in :: =pre.slime:129:24=
- defined in :: =pre.slime:158:24=
- type :: =:macro=
- arguments :: :
- postitional :: =name=:
- rest :: =body=
- docu :: none
\hrule
* =ttt=

- type :: =:lambda=
- arguments :: :
- postitional :: =a=, =b=
- docu :: none
\hrule
* =null?=

- type :: =:lambda=
@@ -590,6 +615,30 @@ ithe sequence as arguemens.
Checks if the argument is =nil=.
#+END:
\hrule
* =type=?=

- type :: =:lambda=
- arguments :: :
- postitional :: =obj=, =typ=
- docu ::
#+BEGIN:
Checks if the argument =obj= is of type =typ=
#+END:
\hrule
* =types=?=

- type :: =:lambda=
- arguments :: :
- rest :: =objs=
- docu :: none
\hrule
* =assert-types==

- type :: =:lambda=
- arguments :: :
- rest :: =objs=
- docu :: none
\hrule
* =number?=

- type :: =:lambda=
@@ -762,6 +811,13 @@ with (pair elem nil).
Returns the length of the given sequence.
#+END:
\hrule
* =member?=

- type :: =:lambda=
- arguments :: :
- postitional :: =elem=, =seq=
- docu :: none
\hrule
* =sublist-starting-at-index=

- type :: =:lambda=
@@ -905,9 +961,237 @@ 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 :: =d:\Code\Gitlab\slime\bin\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:743:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
TODO
#+END:
\hrule
* =car=

- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:753:0=
- type :: =:cfunction=
- docu ::
#+BEGIN:
TODO
#+END:
\hrule
* =cdr=

- defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:764: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=
- defined in :: =d:\Code\Gitlab\slime\bin\oo.slime:22:22=
- type :: =:macro=
- arguments :: :
- postitional :: =name-and-members=:
@@ -919,7 +1203,7 @@ Macro for creating simple classes.
\hrule
* =->=

- defined in :: =oo.slime:25:24=
- defined in :: =d:\Code\Gitlab\slime\bin\oo.slime:25:24=
- type :: =:macro=
- arguments :: :
- postitional :: =obj=, =meth=:
@@ -935,7 +1219,7 @@ Macro for creating simple classes.
\hrule
* =math-> pi=

- defined in :: =math.slime:5:4=
- defined in :: =d:\Code\Gitlab\slime\bin\math.slime:5:4=
- type :: =:number=
- value :: =3.141593=
- docu ::
@@ -945,7 +1229,7 @@ Tha famous circle constant.
\hrule
* =math-> abs=

- defined in :: =math.slime:9:4=
- defined in :: =d:\Code\Gitlab\slime\bin\math.slime:9:4=
- type :: =:lambda=
- arguments :: :
- postitional :: =x=
@@ -956,7 +1240,7 @@ Accepts one argument and returns the absoulte value of it
\hrule
* =math-> sqrt=

- defined in :: =math.slime:13:4=
- defined in :: =d:\Code\Gitlab\slime\bin\math.slime:13:4=
- type :: =:lambda=
- arguments :: :
- postitional :: =x=
@@ -978,7 +1262,7 @@ This is the handle to an object of the class vector3
\hrule
* =math-> make-vector3 define-class=

- defined in :: =oo.slime:22:22=
- defined in :: =d:\Code\Gitlab\slime\bin\oo.slime:22:22=
- type :: =:macro=
- arguments :: :
- postitional :: =name-and-members=:
@@ -990,7 +1274,7 @@ Macro for creating simple classes.
\hrule
* =math-> make-vector3 ->=

- defined in :: =oo.slime:25:24=
- defined in :: =d:\Code\Gitlab\slime\bin\oo.slime:25:24=
- type :: =:macro=
- arguments :: :
- postitional :: =obj=, =meth=:


+ 1
- 1
manual/manual.org Parādīt failu

@@ -948,7 +948,7 @@ embedded scripting language.
#+mail: felix.brendel@airmail.cc
#+options: H:2 toc:nil

#+macro: slime_header (eval (concat "#+header: :exports both" "\n" "#+attr_latex: :options keywordstyle=\\color{slimeKeyword}, commentstyle=\\color{slimeComment}, stringstyle=\\color{slimeString}"))
#+macro: slime_header (eval (concat "#+header: :cache yes :exports both" "\n" "#+attr_latex: :options keywordstyle=\\color{slimeKeyword}, commentstyle=\\color{slimeComment}, stringstyle=\\color{slimeString}"))
#+macro: ditaa_header (eval (concat "#+header: :exports results :cmdline --no-separation --no-shadows"))

#+latex_class:article


+ 3
- 5
src/built_ins.cpp Parādīt failu

@@ -48,7 +48,7 @@ proc built_in_load(String* file_name, Environment* env) -> Lisp_Object* {

fullpath[0] = '\0';
sprintf(fullpath, "%s%s", exe_path, Memory::get_c_str(file_name));
printf("Fullpath: %s\n", fullpath);
// printf("Fullpath: %s\n", fullpath);
file_content = read_entire_file(fullpath);

if (!file_content) {
@@ -466,14 +466,12 @@ proc load_built_ins_into_environment(Environment* env) -> void {

bool truthy;
try truthy = is_truthy(condition, env);
// printf("arg len is: %d\n", arguments_length);
Lisp_Object* result;

if (truthy)
try result = eval_expr(then_part->value.pair.first, env);
else if (arguments_length == 3)
else
try result = eval_expr(else_part->value.pair.first, env);
else return Memory::nil;

return result;
});


+ 4
- 2
src/eval.cpp Parādīt failu

@@ -518,8 +518,10 @@ proc interprete_stdin(bool is_emacs_repl = false) -> void {
delete_error();
continue;
}
print(evaluated);
if (evaluated != Memory::nil) {
print(evaluated);
printf("\n");
}
}
printf("\n");
}
}

+ 1
- 0
src/testing.cpp Parādīt failu

@@ -630,6 +630,7 @@ proc run_all_tests() -> bool {
printf("\n-- Test Files --\n");

invoke_test_script("alists");
invoke_test_script("case_and_cond");
invoke_test_script("evaluation_of_default_args");
invoke_test_script("lexical_scope");
invoke_test_script("class_macro");


+ 4
- 1
todo.org Parādīt failu

@@ -1,8 +1,10 @@
* TODO create global environment- and callstack
* TODO rename slime to plisk
* TODO rename modifying functions to prefix '!'
* TODO go through sicp and use the examples as test files


* TODO test macro expanding to macro
* TODO create global environment- and callstack
* TODO BUG 1: eval dot notation
#+BEGIN_SRC lisp
(eval `(+ . ,(list 1 2 3)))
@@ -18,3 +20,4 @@
;; should output 6
;; outputs 0
#+END_SRC


Notiek ielāde…
Atcelt
Saglabāt