No registered users in community xowiki
in last 10 minutes
in last 10 minutes
Re: [Xotcl] two procs (-proc) for Attribute
From: Stefan Sobernig <stefan.sobernig_at_wu.ac.at>
Date: Mon, 20 Jul 2009 12:50:39 +0200
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
Date: Mon, 20 Jul 2009 12:50:39 +0200
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