MCPcopy Index your code
hub / github.com/clojure/clojure / intern

Method intern

src/jvm/clojure/lang/Namespace.java:63–94  ·  view source on GitHub ↗
(Symbol sym)

Source from the content-addressed store, hash-verified

61}
62
63public Var intern(Symbol sym){
64 if(sym.ns != null)
65 {
66 throw new IllegalArgumentException("Can't intern namespace-qualified symbol");
67 }
68
69 IPersistentMap map = getMappings();
70 Object o;
71 Var v = null;
72 while((o = map.valAt(sym)) == null)
73 {
74 if(v == null)
75 v = new Var(this, sym);
76 IPersistentMap newMap = map.assoc(sym, v);
77 mappings.compareAndSet(map, newMap);
78 map = getMappings();
79 }
80 if(isInternedMapping(sym, o))
81 return (Var) o;
82
83 if(v == null)
84 v = new Var(this, sym);
85
86 if(checkReplacement(sym, o, v)){
87 while (!mappings.compareAndSet(map, map.assoc(sym, v)))
88 map = getMappings();
89
90 return v;
91 }
92
93 return (Var) o;
94}
95
96/*
97 This method checks if a namespace's mapping is applicable and warns on problematic cases.

Callers

nothing calls this directly

Calls 6

getMappingsMethod · 0.95
assocMethod · 0.95
isInternedMappingMethod · 0.95
checkReplacementMethod · 0.95
valAtMethod · 0.65
compareAndSetMethod · 0.65

Tested by

no test coverage detected