I need a touch of macro help! With emscripten, I’ve got a module that spits out a function which, when evaluated, returns an object with all the functions available from a transpiled C thing. (This is for http://github.com/willcohen/clj-proj, which builds a C library.) In other words, (.-_proj_context_create (proj-emscripten)) gives me the function that in C would have been _proj_context_create . I’d love to create a macro that lets me simplify this to something like (foo _proj_context_create) , which I can then apply arguments to.
I’ve got the following, which isn’t quite working, yielding _proj_context_create is not defined rather than returning JS function
(defmacro foo
[f]
`(.-~f (proj-emscripten))))Macroexpansion adds a space between - and the value of f.
You gotta construct a symbol, something like ~(symbol (str ".-" (name f))).
Thank you! Still not working, need to diagnose further on my own. Might be something funny about how macros are working in cherry.
What are the current symptoms of "not working"? What does macroexpand-1 say?
Ah, that’s it. cherry hasn’t implemented macroexpand yet, so this case of the symbol is probably still an edge case there. Will try to create a test case based on what comes out of the JS and work with @borkdude accordingly. Thank you!
I am trying to import a hook from material ui but cant figure it out Any of the attempts I've tried just return nil.
["@mui/x-tree-view/hooks" :refer [useTreeViewApiRef]]
(def tree-api (dbg useTreeViewApiRef))
undefined
the example
https://codesandbox.io/embed/c43mdf?module=/src/Demo.tsx&fontsize=12
the tsx is
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';
Using npm and webpackTry importing the whole package with an alias via :as and then log it to the JS console to see what's inside.
Its still undefined for some of the other packages
["@mui/x-tree-view/TreeItem" :as MuiTreeItem]
that works
I wonder if its the way they package and export librairesSo you did ["@mui/x-tree-view/hooks" :as something] and (js/console.log something) printed out undefined?
Hmm.
I just tried it, and it worked.
So strange
It also worked with ["@mui/x-tree-view/hooks" :refer [useTreeViewApiRef]].
But I'm using shadow-cljs. Don't know what you're using.
That is probably the issue I am using figwheel
Why is shadow able to do this but figwheel fails?
I don't know, I have stopped using Fighweel a long time ago.