mirror of
https://github.com/carp-lang/Carp.git
synced 2024-10-11 12:37:32 +03:00
65 lines
1.2 KiB
Plaintext
65 lines
1.2 KiB
Plaintext
(reset! echo-signature-after-bake true)
|
|
|
|
(when (not carp-dev)
|
|
(do
|
|
;;(load-lisp (str carp-dir "lisp/string_array.carp"))
|
|
;;(load-lisp (str carp-dir "lisp/glfw_test.carp"))
|
|
(load-lisp (str carp-dir "lisp/examples.carp"))
|
|
nil
|
|
))
|
|
|
|
(def x '(1 2 3))
|
|
|
|
(defn id [x] x)
|
|
|
|
(defn id-test []
|
|
(id 123))
|
|
|
|
(def iast (lambda-to-ast (code id-test)))
|
|
|
|
;; (def icon (gencon iast)) <-- KRASCH!
|
|
;; (def iasta (annotate-ast iast))
|
|
|
|
;;(meta-set! x :dangerous 10)
|
|
|
|
(defn whatever [a b]
|
|
100)
|
|
|
|
(defn test-whatever-1 []
|
|
(whatever 1 2))
|
|
|
|
(defn test-whatever-2 []
|
|
(whatever "hej" "svejs"))
|
|
|
|
;; (bake test-whatever-1)
|
|
|
|
|
|
(defstruct Vec2 [x :float y :float])
|
|
|
|
(def v (Vec2 3.0 4.0))
|
|
|
|
(def x (#x v))
|
|
(def y (#y v))
|
|
|
|
;; pretend that the FauxVec2 type in shared.h is the same as Vec2 (they have the same memory layout):
|
|
(register-builtin "position" '() :Vec2)
|
|
|
|
(defn print-vec2 [m]
|
|
(println (str (#x m) ", " (#y m))))
|
|
|
|
(defstruct Mix [a :int b :float c :int])
|
|
|
|
(def m (Mix 10 3.2 20))
|
|
|
|
(defn print-mix [m]
|
|
(println (str "Mix: " (#a m) ", " (#b m) ", " (#c m))))
|
|
|
|
(defstruct Mix2 [mix-a :Mix mix-b :Mix])
|
|
(def m2 (Mix2 (Mix 1 2.0 3) (Mix 4 5.0 6)))
|
|
|
|
(defn test-mix2 []
|
|
(do
|
|
(print-mix (#mix-a m2))
|
|
(print-mix (#mix-b m2))))
|
|
|