Welcome! Please see the About page for a little more info on how this works.

0 votes
in Syntax and reader by

The proposal is to allow the reader to accept symbol names with leading slashes.

Problem: Leading slashes are frequently useful, e.g. in mathematical operators like "/" or "/="

Currently, only "/" is allowed as a special case, and is used for the division operator in clojure.core

This could be extended to allow all symbols to have names starting with a leading slash.

There should be no ambiguity with namespace-qualified symbols:
1) In the case of a leading slash, a symbol should be interpreted as an unqualified symbol e.g. "/="
2) In the case of a slash anywhere except in leading position, it should considered as namespace qualified, e.g. "clojure.core/+"
3) In the case of multiple non-leading slashes, the first slash is the namespace separator, e.g. "clojure.core.matrix.operators//="

Optionally, it also would be possible to allow multiple slashes after the leading slash in a name. This would allow symbols such as "/src/main/clojure" to become valid.

5 Answers

0 votes
by

Comment made by: pparkkin

Attached patch to allow leading slashes in symbol names.

The patch changes the regexp pattern used to match symbols to accept characters after a slash in symbol names.

Tests pass, and the patch also adds a couple of new special cases to the symbol tests.

0 votes
by

Comment made by: jafingerhut

Paavo, a commit made to Clojure master earlier today causes your patch clj-1324-1.patch to no longer apply cleanly. I haven't investigated in detail, but it might be straightforward to update the patch so that it applies cleanly again.

0 votes
by

Comment made by: pparkkin

Attached updated patch.

0 votes
by

Comment made by: jafingerhut

It would be less confusing if you could name the patches differently, or remove the older one.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1324 (reported by mikera)
...