Fork me on GitHub
#clojure
<
2019-06-02
>
James Vickers18:06:10

How would I quote the symbol /= ? '= is fine, '/ is fine, but /= says unmatched delimiter: ). Do I need to escape the slash or something?

dpsutton18:06:20

[[email protected] datascript-todo]$ clj
Clojure 1.9.0
user=> (quote \=)
\=
user=> '\=
\=
i'm guessing this is an issue with your repl?

James Vickers18:06:38

That's backslash, I was trying with forward slash

dpsutton18:06:37

oh apologies

dpsutton18:06:21

> /' has special meaning, it can be used once in the middle of a symbol to separate the namespace from the name, e.g. my-namespace/foo. '/' by itself names the division function.

dpsutton18:06:45

that's not a valid symbol is what i'm reading there

James Vickers18:06:10

yeah even this doesn't work: (read-string "/=") => invalid token: /=

sogaiu18:06:37

in jvm clojure i get Syntax error for (def /= 1)

sogaiu18:06:52

in clojurescript i get Failed to read

James Vickers18:06:06

so i'm making a toy library for array syntax to learn macros

James Vickers18:06:16

and was trying to support e.g. a[0][1] /= 2

James Vickers18:06:43

but I can't define a symbol /= to recognize

sogaiu18:06:20

perhaps because / is used for <namespace>/<name> like situations?

James Vickers18:06:32

yeah just not sure how to work around it

sogaiu18:06:40

perhaps there is no workaround

dpsutton18:06:46

not sure you can. same as you can't make bob) a symbol

James Vickers18:06:18

I guess I'd have to recognize it as a string

James Vickers18:06:32

like turn the list body into a string and parse it

dpsutton18:06:17

if you're breaking in the reader i'm not sure you can do that

James Vickers18:06:46

I think I could turn the body into a string and find /= in the string and handle it accordingly

dpsutton18:06:49

unless you mean turn it into a string literal

James Vickers18:06:03

but it would probably mean I'd have to do all the other cases (e.g. *= the same way) 😕

andy.fingerhut18:06:03

If you are trying to "write a language" with Clojure macros that has the full library of Clojure available as well, then I'd recommend using a different symbol than /=, e.g. div=, even if that looks ugly.

andy.fingerhut18:06:01

If you are trying to write a language with its own custom syntax, and you are writing a compiler in Clojure to translate it into some other language that isn't Clojure, then you should be able to define whatever syntax you want that you can write a parser for. I am guessing that is not what you are trying to do, though.