Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"module style" chialisp. moves toplevel forms to the top level (instead of enclosed) and allows import to be more intelligent ala es2015. Introduces namespaces. #62

Draft
wants to merge 79 commits into
base: staging
Choose a base branch
from

Conversation

prozacchiwawa
Copy link
Contributor

@prozacchiwawa prozacchiwawa commented Jan 4, 2024

new forms:

(import std.prelude) ;; spills contents of std.prelude into the current namespace
(import qualified std.hash) ;; if shatree is in std.hash, adds std.hash.shatree into this namespace
(import qualified std.hash as H) ;; as above, but adds H.shatree
(import std.hash exposing shatree sha) ;; Adds only shatree and sha to the current namespace
(import std.hash hiding sha) ;; adds shatree to the current namespace

(export (args) body) ;; Creates one clvm program (as with toplevel mod)

(defun F (X) ...)
(defun G (X) ...)
(export F) ;; creates a program from F and writes it to disk
(export G) ;; also G simultaneously

;; Module style provides the hashes of exports to the program exporting them,
;; making it possible to build some coin structures entirely within a chialisp program.
;; The hash functions will be arranged to be as efficient as they can be (constant if
;; not recursively defined, otherwise with as much precalculation as possible).
(defun F (X) (G_hash)) ;; Construct the modhash of G if it's exported
(defun G (X) (F_hash)) ;; Construct the modhash of F if it's exported

example of what can be got up to:

(include *standard-cl-23*)
(import qualified programs.two-outputs as two.outputs)

;; When imported, F_hash and G_hash of foreign programs are constants.
(export (X Y) (list two.outputs.F_hash (a two.outputs.F (list X)) two.outputs.F two.outputs.G_hash (a two.outputs.G (list Y)) two.outputs.G))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant