Hello all,
I downloaded XOTcl 1.6.0 today, and I immediately ran into an issue in some of my existing code. The following example works in XOTcl 1.5.6, but is different in XOTcl 1.6.0 -- as I understand the documentation on the website, there should be no difference between versions.
package require XOTcl namespace import ::xotcl::* Class Foo set f [Foo new] $f info Class ;# returns "::Foo", which seems correct $f info Class "Foo" ;# in 1.5.6, returns 1; in 1.6.0, returns an empty string
To repeat, the issue is that "Object info class <classname>" returns a boolean value in XOTcl 1.5.6, but returns an empty string in 1.6.0 -- the current documentation on the website suggests that the 1.5.6 behavior is correct.
Am I missing something? Should the documentation be changed, or is the behavior in 1.6.0 incorrect? I downloaded the package via ActiveState's teacup service; I'm working on Mac OS X 10.4 Intel.
Thanks in advance for any help!
Cheers, Edmond
Dear Edmond,
Thanks for noting this. There is indeed a bug in this version concerning info class, at least a documentation bug.
"<obj> info class ?pattern?" is implemented in the case a pattern is given internally by the means of in info superclass. "info superclass ?-closure? ?pattern?" was changed together with other info options (see changelog). Since "info" is not fully backwards compatible, the major release number changed.
The recommended way to check, if an object is of a certain type (is a direct/indirect instance of a certain class) is to use "istype".
% Class Foo ::Foo % Foo f ::f % f istype Foo 1 % f istype Object 1
The old interface matches only with the superclass elements, when pattern is specified. There are essentially two options to proceed:
(a) "info class ?pattern?" could be fixed to match with the current class and the superclasses, but then it should return always empty, when the pattern does not match, as it is now in accordance to other cases, where ?pattern? is used.
(b) It is as well possible to remove the ?pattern? argument from "info class", since there is as well istype. Note that there is as well "info precedence ?pattern?", which returns the resolution order including mixins and superclasses.
approach (a) makes it easy to query the classes either with or without mixins, but to get the full list, one should use "[f info class] info superclass -closure", or we implement as well a "info class -closure".
Or in the case (b) "info precedence" could get an option to list only intrinsic classes (classes which are no mixins). One can use a single method to get a full or partial list, and one can use ?pattern? to filter the list in a uniform way.
Opinions?
best regards -gustaf neumann
Edmond Ho schrieb:
Hello all,
I downloaded XOTcl 1.6.0 today, and I immediately ran into an issue in some of my existing code. The following example works in XOTcl 1.5.6, but is different in XOTcl 1.6.0 -- as I understand the documentation on the website, there should be no difference between versions.
package require XOTcl namespace import ::xotcl::* Class Foo set f [Foo new] $f info Class ;# returns "::Foo", which seems correct $f info Class "Foo" ;# in 1.5.6, returns 1; in 1.6.0, returns an empty string
To repeat, the issue is that "Object info class <classname>" returns a boolean value in XOTcl 1.5.6, but returns an empty string in 1.6.0 -- the current documentation on the website suggests that the 1.5.6 behavior is correct.
Am I missing something? Should the documentation be changed, or is the behavior in 1.6.0 incorrect? I downloaded the package via ActiveState's teacup service; I'm working on Mac OS X 10.4 Intel.
Thanks in advance for any help!
Cheers, Edmond
Xotcl mailing list Xotcl@alice.wu-wien.ac.at http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
Hello Gustaf,
Thanks for your reply!
The recommended way to check, if an object is of a certain
type (is a direct/indirect instance of a certain class) is to use "istype".
I replaced all of my calls to "Object info class ?pattern?" to "Object istype ?pattern?" and it works well. Out of curiosity, is the "istype" method new to 1.6.0?
The old interface matches only with the
superclass elements, when pattern is specified. There are essentially two options to proceed:
(a) "info class ?pattern?" could be fixed to match with the current class and the superclasses, but then it should return always empty, when the pattern does not match, as it is now in accordance to other cases, where ?pattern? is used.
(b) It is as well possible to remove the ?pattern? argument from "info class", since there is as well istype. Note that there is as well "info precedence ?pattern?", which returns the resolution order including mixins and superclasses.
approach (a) makes it easy to query the classes either with or without mixins, but to get the full list, one should use "[f info class] info superclass -closure", or we implement as well a "info class -closure".
Or in the case (b) "info precedence" could get an option to list only intrinsic classes (classes which are no mixins). One can use a single method to get a full or partial list, and one can use ?pattern? to filter the list in a uniform way.
Opinions?
To me, option (b) seems clearer. Type checking is simplified to the use of "istype", while "info" is focused on more advanced introspection. However, I'm new to XOTcl, so I may not be thinking ahead to interaction with the advanced features. I'm sure you guys will make the best decision!
The only thing I'll ask for here is the updated documentation on the website. I also think that there should be documentation for each major version of XOTcl on the website, so that it's clearer as what the differences are between versions. Just my two cents.
Thanks again!
Cheers, Edmond