Fork me on GitHub
#clojurescript
<
2019-09-20
>
herald09:09:42

I remember seeing a way here to turn a clojurescript var into some string, then calling a function to turn that string back into a reference to the same var. Anyone know how to do this?

arohner15:09:11

How do I write export default in CLJS?

dnolen15:09:23

@arohner there's no way to do that directly

arohner15:09:52

For context, I’m trying to use https://storybook.js.org/docs/guides/guide-react/, and they want it

arohner15:09:58

import React from 'react';
import { Button } from '@storybook/react/demo';

export default { title: 'Button' };

export const withText = () => <Button>Hello Button</Button>;

export const withEmoji = () => (
  <Button><span role="img" aria-label="so cool">πŸ˜€ 😎 πŸ‘ πŸ’―</span></Button>
);

simonkatz15:09:26

Are there any libraries that abstract mathematical functions in Clojure and ClojureScript so that both work roughly the same? I’m thinking of things like rounding, exponents, logs. For the moment I’m using conditional compilation, Math for ClojureScript and a mixture of Math and clojure.math.numeric-tower for Clojure. But I don’t know how well this will work out.

deadghost17:09:37

How are required namespaces/functions used in the macro file? Can I require in cljs library functions or do functions always need to be fully qualified?

David Pham17:09:27

I am not a macro expert, but if I understand them correctly, if you use your macro in a different namespace you might call the wrong function.

andy.fingerhut17:09:32

If you write a macro using the backtick, e.g. `map will resolve when the symbol is read to clojure.core/map, or whatever map resolves to in the namespace where the macro was defined, and the full namespace qualified version is what actually gets included in the definition of the macro. That makes it straightforward to know that when you call such macros, it will not use a local version of 'map', for example.

andy.fingerhut17:09:07

You can of course choose to write macros that do use a local version of a name where the macro is invoked, but it is at the choice of the writer of the macro.

andy.fingerhut17:09:01

And I should add that I am more experienced with macros in Clojure/Java than ClojureScript, so what I said above is accurate for Clojure/Java, but hopefully someone more knowledgeable of ClojureScript macros will correct any mistakes there if it is different.