No registered users in community xowiki
in last 10 minutes
in last 10 minutes
Re: [Xotcl] XOTcl 1.6.0 issue with "Object info class"
From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Mon, 10 Mar 2008 08:42:49 +0100
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_at_alice.wu-wien.ac.at
> http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
>
Date: Mon, 10 Mar 2008 08:42:49 +0100
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_at_alice.wu-wien.ac.at
> http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
>