diff options
author | Rich Hickey <richhickey@gmail.com> | 2006-03-27 12:51:24 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2006-03-27 12:51:24 +0000 |
commit | f4f532eecf07fb55ba43a4fb5258b09a32a6bc3d (patch) | |
tree | f336a3a2d1091986fec0b404d3d55f0e2e9fbccf /src | |
parent | 428aa9c52d4cd274b0cfa3097e9661d76a7ea884 (diff) |
implemented IFn for attr access
Diffstat (limited to 'src')
-rw-r--r-- | src/org/clojure/runtime/Symbol.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/org/clojure/runtime/Symbol.java b/src/org/clojure/runtime/Symbol.java index c5276982..c56c8b76 100644 --- a/src/org/clojure/runtime/Symbol.java +++ b/src/org/clojure/runtime/Symbol.java @@ -12,5 +12,32 @@ package org.clojure.runtime; -public class Symbol extends AMap{ +public class Symbol extends AFn{ + +/** + * Symbol implements IFn for attr access + * This single arg version is the getter + * @param tld + * @param obj - must be AMap + * @return the value of the attr or nil if not found + * @throws Exception + */ +public Object invoke(ThreadLocalData tld, Object obj) throws Exception + { + return ((AMap)obj).get(this); + } + +/** + * Symbol implements IFn for attr access + * This two arg version is the setter + * @param tld + * @param obj - must be AMap + * @param val + * @return val + * @throws Exception + */ +public Object invoke(ThreadLocalData tld, Object obj, Object val) throws Exception + { + return ((AMap)obj).put(this,val); + } } |