Fork me on GitHub
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?


[dan@fedora 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


oh apologies


> /' 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.


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: /=


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


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


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

James Vickers18:06:32

yeah just not sure how to work around it


perhaps there is no workaround


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


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


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) 😕


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.


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.