[CLJ-1411] Special symbols can be shadowed inconsistently Created: 28/Apr/14 Updated: 29/Apr/14
|Affects Version/s:||Release 1.6|
|Reporter:||Volkert Oakley Jurgens||Assignee:||Unassigned|
The compiler does not complain about let binding (or def-ing) special symbols, but the binding only works if not used at the beginning of a list:
This doesn't work:
This is true for all special symbols, not just publicly exposed ones like try and new, but also internal ones like fn*.
I would expect consistent behaviour: either the compiler does not permit shadowing special symbols at all, or shadowing them works in all cases.
|Comment by Nicola Mometto [ 28/Apr/14 10:01 AM ]|
I don't think that shadowing special symbols is a good idea, but probably having all the special symbols namespace qualified (clojure.core/import* is the only one ns-qualified atm) along with checking for the symbol in the locals env first and fallbacking to the special symbols map after that, would probably help in those scenarios
|Comment by Volkert Oakley Jurgens [ 29/Apr/14 12:48 AM ]|
I think that shadowing special symbols is a bad idea. If that was possible, we'd have to change most macros in clojure.core to make them safe (i.e. explicitly add a namespace to each special symbol usage). And how would we handle special symbols that are not just implementation specific, like try and new? Every 3rd party macro that uses those might become unsafe.
My personal preference would be to prohibit the shadowing of special symbols.
|Comment by Nicola Mometto [ 29/Apr/14 5:37 AM ]|
That won't be the case since what I'm proposing includes making syntax-quote aware of the namespaced special symbols.
|Comment by Volkert Oakley Jurgens [ 29/Apr/14 5:58 AM ]|
That's true, but macros don't have to use the syntax quote. See for example the definition of when.