diff options
| author | Rich Hickey <richhickey@gmail.com> | 2006-09-25 17:54:37 +0000 |
|---|---|---|
| committer | Rich Hickey <richhickey@gmail.com> | 2006-09-25 17:54:37 +0000 |
| commit | 51c468f878a842bc6e469c32acbc58543448d081 (patch) | |
| tree | 269d7766024da9e03a4f15e255c3c73ef8289b93 /src/cli/runtime/Var.cs | |
| parent | 987dad567505261e0daf3dcbdd6363353cbe15a5 (diff) | |
renamed Namespace to Module
Diffstat (limited to 'src/cli/runtime/Var.cs')
| -rw-r--r-- | src/cli/runtime/Var.cs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cli/runtime/Var.cs b/src/cli/runtime/Var.cs index cb0327e7..626c4f48 100644 --- a/src/cli/runtime/Var.cs +++ b/src/cli/runtime/Var.cs @@ -15,11 +15,11 @@ namespace clojure.lang {
public class Var : AFn
{
-public readonly Symbol sym;
public Namespace ns;
public Binding binding;
volatile IPersistentMap threadBindings = PersistentArrayMap.EMPTY;
volatile int tcount = 0;
internal Var(Symbol sym, Namespace ns)
{
if(sym.GetType() != typeof(Symbol))
throw new ArgumentException("Only simple symbols can be vars");
this.ns = ns;
this.sym = sym;
}
override public String ToString()
{
if(ns == null)
return "#:" + sym;
return ns.name + ":" + sym;
}
public Var bind(Object val)
{
if(binding == null)
+public readonly Symbol name;
public Module module;
public Binding binding;
IPersistentMap threadBindings = PersistentArrayMap.EMPTY;
int tcount = 0;
internal Var(Symbol sym, Module ns)
{
if(sym.GetType() != typeof(Symbol))
throw new ArgumentException("Only simple symbols can be var names");
this.module = ns;
this.name = sym;
}
override public String ToString()
{
if(module == null)
return "#:" + name;
return module.name + ":" + name;
}
public Var bind(Object val)
{
lock(this){
if(binding == null)
binding = new Binding(val);
else
binding.val = val;
- return this;
}
public Object getValue()
{
- Binding binding = getBinding();
if(binding != null)
return binding.val;
throw new InvalidOperationException(this.ToString() + " is unbound.");
}
public Object setValue(Object val)
{
+ return this;
}
}
public Object getValue()
{
+ Binding b = getBinding();
if(b != null)
return b.val;
throw new InvalidOperationException(this.ToString() + " is unbound.");
}
public Object setValue(Object val)
{
Binding b = getThreadBinding();
if(b != null)
return b.val = val;
if(binding == null)
throw new InvalidOperationException(this.ToString() + " is unbound.");
return binding.val = val;
}
|
