[Xotcl] two procs (-proc) for Attribute
Stefan Sobernig
stefan.sobernig at wu.ac.at
Mon Jul 20 12:50:39 CEST 2009
Mykhaylo,
> How to define several procs for one Attribute in class definition?
> Particularly, I want to define both assign and get procs at once.
i am not entirely confident that i grasbed the meanings of "serveral
procs for one Attribute" and "at once". Do you mean:
a) define 2 or more (per-object methods, i.e., procs) per slot object
"at once"?
b) define 2 (per-instance methods, i.e., instprocs) per family of slot
objects "at once"?
anyways, maybe some of the following is helpful to you:
#
# ad a)
#
Class create C -slots {
Attribute create a1 -proc assign args {
puts "[self]->[self proc] called"
next
} -proc get args {
puts "[self]->[self proc] called"
next
}
}
C create c
c a1 1
c a1
#
# ad b)
#
Class MyAttribute -superclass Attribute \
-instproc assign args {
puts "[self]->[self proc] called"
next
} -instproc get args {
puts "[self]->[self proc] called"
next
}
Class create D -slots {
MyAttribute create a1
Attribute create a2
}
D create d
d a1 1
d a1
More information about the Xotcl
mailing list