dasylang / dasy

a lisp built on top of vyper
49 stars 2 forks source link

+title: Dasy

+EXPORT_FILE_NAME: index

+SETUPFILE: https://fniessen.github.io/org-html-themes/org/theme-readtheorg.setup

+begin_quote

The Dasypeltis, gansi, is considered an egg-eating snake. Their diet consists of all forms of eggs considering they have no teeth in which to eat living prey with.

+end_quote

Dasy is an experimental smart contract programming language in the lisp family. It is implemented by compiling to Vyper and benefits from the extensive optimizations and excellent performance of Vyper.

Learn more in the [[file:docs.org][documentation]]

(defn init [] :external (set self/owner msg/sender) (set-at self/myMap msg/sender 10) (do ;; wrap statements in do (.append self/nums 11)))

(defn getOwnerNum [] :uint256 :external (get-at self/myMap self/owner))

+end_src

macros are written in Hy, a pythonic lisp. They allow us to transform our code at compile time, allowing the developer to tailor the language itself to their needs.

=cond= and =condp= are examples of useful macros that help make your code shorter, yet easier to understand.

+begin_src clojure

(defn useIf [:uint256 x] :uint256 :external (if (<= x 10) (return 1) (if (<= x 20) (return 2) (return 3))))

;; cond macro helps prevent deeply nested ifs (defn useCond [:uint256 x] :uint256 :external (cond (<= x 10) (return 1) (<= x 20) (return 2) :else (return 3)))

;; condp saves you from repeating the same operation (defn useCondp [:uint256 x] :uint256 :external (condp <= x 10 (return 1) 20 (return 2) :else (return 3)))

+end_src

** For fun