mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
Renamed 'defdynamic' to 'defndynamic'.
This commit is contained in:
parent
b3ded89e0e
commit
0049c13111
@ -5,7 +5,7 @@
|
||||
(doc sanitize-addresses "instructs the compiler to sanitize addresses.
|
||||
|
||||
This might not work on all compilers, but reasonably new versions of GCC and Clang are supported.")
|
||||
(defdynamic sanitize-addresses []
|
||||
(defndynamic sanitize-addresses []
|
||||
(add-cflag "-fsanitize=address"))
|
||||
|
||||
(register memory-balance (Fn [] Long))
|
||||
|
@ -1,15 +1,15 @@
|
||||
(defmodule Dynamic
|
||||
;; Functions for doing things at the REPL and during compile time.
|
||||
|
||||
(defdynamic inc [x]
|
||||
(defndynamic inc [x]
|
||||
(+ x 1))
|
||||
|
||||
(defdynamic dec [x]
|
||||
(defndynamic dec [x]
|
||||
(- x 1))
|
||||
|
||||
(defmodule Project
|
||||
(doc no-echo "Turn off debug printing in the compiler.")
|
||||
(defdynamic no-echo []
|
||||
(defndynamic no-echo []
|
||||
(do
|
||||
(Project.config "print-ast" false)
|
||||
(Project.config "echo-compiler-cmd" false))))
|
||||
@ -19,8 +19,8 @@
|
||||
|
||||
;; The following functions are not put into a module for now:
|
||||
|
||||
(defdynamic add-cflag [flag]
|
||||
(defndynamic add-cflag [flag]
|
||||
(Project.config "cflag" flag))
|
||||
|
||||
(defdynamic add-lib [lib]
|
||||
(defndynamic add-lib [lib]
|
||||
(Project.config "libflag" lib))
|
||||
|
@ -1,6 +1,6 @@
|
||||
(private fmt-internal)
|
||||
(hidden fmt-internal)
|
||||
(defdynamic fmt-internal [s args]
|
||||
(defndynamic fmt-internal [s args]
|
||||
(let [idx (String.index-of s \%)
|
||||
len (String.length s)]
|
||||
(if (= idx -1)
|
||||
|
@ -34,36 +34,36 @@
|
||||
|
||||
|
||||
(defmodule Dynamic
|
||||
(defdynamic caar [pair] (car (car pair)))
|
||||
(defdynamic cadr [pair] (car (cdr pair)))
|
||||
(defdynamic cdar [pair] (cdr (car pair)))
|
||||
(defdynamic cddr [pair] (cdr (cdr pair)))
|
||||
(defdynamic caaar [pair] (car (car (car pair))))
|
||||
(defdynamic caadr [pair] (car (car (cdr pair))))
|
||||
(defdynamic cadar [pair] (car (cdr (car pair))))
|
||||
(defdynamic cdaar [pair] (cdr (car (car pair))))
|
||||
(defdynamic caddr [pair] (car (cdr (cdr pair))))
|
||||
(defdynamic cdadr [pair] (cdr (car (cdr pair))))
|
||||
(defdynamic cddar [pair] (cdr (cdr (car pair))))
|
||||
(defdynamic cdddr [pair] (cdr (cdr (cdr pair))))
|
||||
(defdynamic caaaar [pair] (car (car (car (car pair)))))
|
||||
(defdynamic caaadr [pair] (car (car (car (cdr pair)))))
|
||||
(defdynamic caadar [pair] (car (car (cdr (car pair)))))
|
||||
(defdynamic caaddr [pair] (car (car (cdr (cdr pair)))))
|
||||
(defdynamic cadaar [pair] (car (cdr (car (car pair)))))
|
||||
(defdynamic cadadr [pair] (car (cdr (car (cdr pair)))))
|
||||
(defdynamic caddar [pair] (car (cdr (cdr (car pair)))))
|
||||
(defdynamic cadddr [pair] (car (cdr (cdr (cdr pair)))))
|
||||
(defdynamic cdaaar [pair] (cdr (car (car (car pair)))))
|
||||
(defdynamic cdaadr [pair] (cdr (car (car (cdr pair)))))
|
||||
(defdynamic cdadar [pair] (cdr (car (cdr (car pair)))))
|
||||
(defdynamic cdaddr [pair] (cdr (car (cdr (cdr pair)))))
|
||||
(defdynamic cddaar [pair] (cdr (cdr (car (car pair)))))
|
||||
(defdynamic cddadr [pair] (cdr (cdr (car (cdr pair)))))
|
||||
(defdynamic cdddar [pair] (cdr (cdr (cdr (car pair)))))
|
||||
(defdynamic cddddr [pair] (cdr (cdr (cdr (cdr pair)))))
|
||||
(defndynamic caar [pair] (car (car pair)))
|
||||
(defndynamic cadr [pair] (car (cdr pair)))
|
||||
(defndynamic cdar [pair] (cdr (car pair)))
|
||||
(defndynamic cddr [pair] (cdr (cdr pair)))
|
||||
(defndynamic caaar [pair] (car (car (car pair))))
|
||||
(defndynamic caadr [pair] (car (car (cdr pair))))
|
||||
(defndynamic cadar [pair] (car (cdr (car pair))))
|
||||
(defndynamic cdaar [pair] (cdr (car (car pair))))
|
||||
(defndynamic caddr [pair] (car (cdr (cdr pair))))
|
||||
(defndynamic cdadr [pair] (cdr (car (cdr pair))))
|
||||
(defndynamic cddar [pair] (cdr (cdr (car pair))))
|
||||
(defndynamic cdddr [pair] (cdr (cdr (cdr pair))))
|
||||
(defndynamic caaaar [pair] (car (car (car (car pair)))))
|
||||
(defndynamic caaadr [pair] (car (car (car (cdr pair)))))
|
||||
(defndynamic caadar [pair] (car (car (cdr (car pair)))))
|
||||
(defndynamic caaddr [pair] (car (car (cdr (cdr pair)))))
|
||||
(defndynamic cadaar [pair] (car (cdr (car (car pair)))))
|
||||
(defndynamic cadadr [pair] (car (cdr (car (cdr pair)))))
|
||||
(defndynamic caddar [pair] (car (cdr (cdr (car pair)))))
|
||||
(defndynamic cadddr [pair] (car (cdr (cdr (cdr pair)))))
|
||||
(defndynamic cdaaar [pair] (cdr (car (car (car pair)))))
|
||||
(defndynamic cdaadr [pair] (cdr (car (car (cdr pair)))))
|
||||
(defndynamic cdadar [pair] (cdr (car (cdr (car pair)))))
|
||||
(defndynamic cdaddr [pair] (cdr (car (cdr (cdr pair)))))
|
||||
(defndynamic cddaar [pair] (cdr (cdr (car (car pair)))))
|
||||
(defndynamic cddadr [pair] (cdr (cdr (car (cdr pair)))))
|
||||
(defndynamic cdddar [pair] (cdr (cdr (cdr (car pair)))))
|
||||
(defndynamic cddddr [pair] (cdr (cdr (cdr (cdr pair)))))
|
||||
|
||||
(defdynamic eval-internal [form]
|
||||
(defndynamic eval-internal [form]
|
||||
(list 'do
|
||||
(list 'defn 'main [] (list 'IO.println* form))
|
||||
(list 'build)
|
||||
@ -77,7 +77,7 @@
|
||||
|
||||
)
|
||||
|
||||
(defdynamic cond-internal [xs]
|
||||
(defndynamic cond-internal [xs]
|
||||
(if (= (length xs) 0)
|
||||
(list)
|
||||
(if (= (length xs) 2)
|
||||
@ -125,7 +125,7 @@
|
||||
;; (list 'for ['i 0 (list 'Array.length (list 'ref xs))]
|
||||
;; (list f (list 'Array.nth (list 'ref xs) 'i))))
|
||||
|
||||
(defdynamic foreach-internal [var xs expr]
|
||||
(defndynamic foreach-internal [var xs expr]
|
||||
(list 'let ['xs xs
|
||||
'len (list 'Array.length 'xs)]
|
||||
(list 'for ['i 0 'len]
|
||||
@ -137,7 +137,7 @@
|
||||
(foreach-internal (car binding) (cadr binding) expr)
|
||||
(macro-error "Binding has to be an array.")))
|
||||
|
||||
(defdynamic thread-first-internal [xs]
|
||||
(defndynamic thread-first-internal [xs]
|
||||
(if (= (length xs) 2)
|
||||
(if (list? (last xs))
|
||||
(cons (caadr xs)
|
||||
@ -152,7 +152,7 @@
|
||||
(cdr (last xs)))
|
||||
(list (last xs) (thread-first-internal (all-but-last xs))))))
|
||||
|
||||
(defdynamic thread-last-internal [xs]
|
||||
(defndynamic thread-last-internal [xs]
|
||||
(if (= (length xs) 2)
|
||||
(if (list? (last xs))
|
||||
(cons-last (car xs) (last xs))
|
||||
@ -193,7 +193,7 @@
|
||||
(cons (quote do) forms)
|
||||
()))
|
||||
|
||||
(defdynamic use-all-fn [names]
|
||||
(defndynamic use-all-fn [names]
|
||||
(if (= (length names) 0)
|
||||
(macro-error "Trying to call use-all without arguments")
|
||||
(if (= (length names) 1)
|
||||
@ -227,7 +227,7 @@
|
||||
(defmacro forever-do [:rest forms]
|
||||
(list 'while true (cons 'do forms)))
|
||||
|
||||
(defdynamic case-internal [name xs]
|
||||
(defndynamic case-internal [name xs]
|
||||
(if (= (length xs) 0)
|
||||
(list)
|
||||
(if (= (length xs) 2)
|
||||
@ -248,7 +248,7 @@
|
||||
(defmacro or [x y]
|
||||
(list 'if x true y))
|
||||
|
||||
(defdynamic build-vararg [func forms]
|
||||
(defndynamic build-vararg [func forms]
|
||||
(if (= (length forms) 0)
|
||||
(macro-error "vararg macro needs at least one argument")
|
||||
(if (= (length forms) 1)
|
||||
@ -261,7 +261,7 @@
|
||||
(defmacro or* [:rest forms]
|
||||
(build-vararg 'or forms))
|
||||
|
||||
(defdynamic build-str* [forms]
|
||||
(defndynamic build-str* [forms]
|
||||
(if (= (length forms) 0)
|
||||
(list "")
|
||||
(if (= (length forms) 1)
|
||||
|
@ -106,7 +106,7 @@
|
||||
(IO.println &(Int.str failed))
|
||||
(IO.color "reset")))))
|
||||
|
||||
(defdynamic with-test-internal [name forms]
|
||||
(defndynamic with-test-internal [name forms]
|
||||
(if (= (length forms) 1)
|
||||
(list (list 'set! name (list 'ref (car forms))))
|
||||
(cons (list 'set! name (list 'ref (car forms)))
|
||||
|
12
src/Eval.hs
12
src/Eval.hs
@ -221,10 +221,10 @@ eval env xobj =
|
||||
XObj (Sym (SymPath [] "definterface") _) _ _ : _ ->
|
||||
return (Left (EvalError ("Invalid args to `definterface`: " ++ pretty xobj) (info xobj) fppl))
|
||||
|
||||
[XObj (Sym (SymPath [] "defdynamic") _) _ _, (XObj (Sym (SymPath [] name) _) _ _), params, body] ->
|
||||
specialCommandDefdynamic name params body
|
||||
XObj (Sym (SymPath [] "defdynamic") _) _ _ : _ ->
|
||||
return (Left (EvalError ("Invalid args to `defdynamic`: " ++ pretty xobj) (info xobj) fppl))
|
||||
[XObj (Sym (SymPath [] "defndynamic") _) _ _, (XObj (Sym (SymPath [] name) _) _ _), params, body] ->
|
||||
specialCommandDefndynamic name params body
|
||||
XObj (Sym (SymPath [] "defndynamic") _) _ _ : _ ->
|
||||
return (Left (EvalError ("Invalid args to `defndynamic`: " ++ pretty xobj) (info xobj) fppl))
|
||||
|
||||
[XObj (Sym (SymPath [] "defmacro") _) _ _, (XObj (Sym (SymPath [] name) _) _ _), params, body] ->
|
||||
specialCommandDefmacro name params body
|
||||
@ -743,8 +743,8 @@ specialCommandDefinterface nameXObj@(XObj (Sym path@(SymPath [] name) _) _ _) ty
|
||||
return (Left (EvalError ("Invalid type for interface '" ++ name ++ "': " ++
|
||||
pretty typeXObj) (info typeXObj) fppl))
|
||||
|
||||
specialCommandDefdynamic :: String -> XObj -> XObj -> StateT Context IO (Either EvalError XObj)
|
||||
specialCommandDefdynamic name params body =
|
||||
specialCommandDefndynamic :: String -> XObj -> XObj -> StateT Context IO (Either EvalError XObj)
|
||||
specialCommandDefndynamic name params body =
|
||||
do ctx <- get
|
||||
let pathStrings = contextPath ctx
|
||||
globalEnv = contextGlobalEnv ctx
|
||||
|
@ -1,7 +1,7 @@
|
||||
(load "Test.carp")
|
||||
(use Test)
|
||||
|
||||
(defdynamic _make-exe-path [pth]
|
||||
(defndynamic _make-exe-path [pth]
|
||||
(String.join (array (Project.get-config "output-directory") pth)))
|
||||
|
||||
(defmacro make-exe-path [pth]
|
||||
|
@ -28,7 +28,7 @@
|
||||
(defmacro test-> [a b] (> a b))
|
||||
(defmacro test-= [a b] (= a b))
|
||||
|
||||
(defdynamic gc- [key] (Project.get-config key))
|
||||
(defndynamic gc- [key] (Project.get-config key))
|
||||
(defmacro gc [key] (gc- key))
|
||||
|
||||
(deftest test
|
||||
|
Loading…
Reference in New Issue
Block a user