Clojure

Allow leading slashes in unqualified symbol names

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    All
  • Patch:
    Code and Test

Description

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.

Activity

Hide
Andy Fingerhut added a comment -

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

Show
Andy Fingerhut added a comment - It would be less confusing if you could name the patches differently, or remove the older one.
Hide
Paavo Parkkinen added a comment -

Attached updated patch.

Show
Paavo Parkkinen added a comment - Attached updated patch.
Hide
Andy Fingerhut added a comment -

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.

Show
Andy Fingerhut added a comment - 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.
Hide
Paavo Parkkinen added a comment -

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.

Show
Paavo Parkkinen added a comment - 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.

People

Vote (0)
Watch (5)

Dates

  • Created:
    Updated: