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

Consider metadata in $.cell/* macro #5

Open
helins opened this issue Nov 4, 2021 · 3 comments
Open

Consider metadata in $.cell/* macro #5

helins opened this issue Nov 4, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@helins
Copy link
Member

helins commented Nov 4, 2021

For instance:

($.cell/*
 (defn ^{:callable? true} set-value-in-actor
   [x]
   (def value
     x)))

However metadata in CVX behave differently so this deserves some thoughts.

@helins helins added the enhancement New feature or request label Nov 4, 2021
@mikera
Copy link
Member

mikera commented Nov 5, 2021

Best if we be consistent with the Reader convention, so that a metadata annotation causes the following form to be wrapped as a Syntax. See: https://github.com/Convex-Dev/convex/blob/22bb34e2a2c680f9eafe674b0f688c41413f746f/convex-core/src/main/java/convex/core/lang/reader/AntlrReader.java#L310

@helins
Copy link
Member Author

helins commented Nov 5, 2021

Yes, essentially, however it's only going on IMeta

@helins
Copy link
Member Author

helins commented Nov 15, 2022

(Follow-up on a Discord question about how to circumvent this for the time being).

The Reader converts ^{:metadata ...} value into to a Syntax (a type that wraps a value alongside a metadata map).

For the time being, using the $.cell/* macro, we can actually do it ourselves using convex.cell/syntax. We can use unquote for feeding any value that is already a cell.

Something like:

($.cell/*
 (defn ~($.cell/syntax ($.cell/* set-value-in-actor)
                       ($.cell/* {:callable? true}))
   [x]
   (def value
     x)))

Not as pretty as a literal notation but it works.

When working with a chunk of Convex Lisp code that does not need to be generated from Clojure, I recommend writing it to a dedicated file and use the reader. Setting your editor to Clojure syntax when writing Convex Lisp files works good enough on average.

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

No branches or pull requests

2 participants