f



Tcl OO mixins and inheritence behaviour change from version 8.6.2 to version 8.6.3

Hi, it seems that implementation of object oriented functionality in tcl8.6.3 changed in a away that breaks my existing code. My test code looks like this: 


oo::class create MixinClass {

  method helloWorld {args} {
    puts "[self class]"
    catch { next }
  }
}


oo::class create BaseClass {

  mixin MixinClass 

  method helloWorld {args} {
    puts "[self class]"
    catch { next }
  }

}

oo::class create TargetClass {

  superclass BaseClass 

  method helloWorld {args} {
    puts "[self class]"
    catch { next }
  }

}


set object [TargetClass new] 

puts [info patch]

$object helloWorld 


I expect that TargetClass can override any method defined in BaseClass or its mixins, is this wrong assumption?


Until version 8.6.3 snippet produces following result (expected result): 

8.6.2
::TargetClass
::MixinClass
::BaseClass


From version 8.6.3 through 8.6.4 produces this result (bug?): 

8.6.4
::MixinClass
::TargetClass
::BaseClass


In 8.6.4 case TargetClass's method seems to be completly obstructed by mixin method and it is not invoked.  

I wonder if anyone knows something about intentional changes to OO implementation in version 8.6.3 or stumbled upon similar problems using tcl oo extension? 








0
phreaman
5/25/2015 12:59:38 PM
comp.lang.tcl 23428 articles. 2 followers. Post Follow

6 Replies
999 Views

Similar Articles

[PageSpeed] 39

On 25/05/2015 13:59, phreaman wrote:
> I wonder if anyone knows something about intentional changes to OO
> implementation in version 8.6.3 or stumbled upon similar problems
> using tcl oo extension?

This was Bug #b9e1a3032e and unfortunately you were relying on the old
behaviour. I slipped up and forgot to note in the commit that this was
an incompatibility with the old system, but it really was wrong.

Bug: http://core.tcl.tk/tcl/tktview?name=b9e1a3032e
Fix: http://core.tcl.tk/tcl/info/ab635c816104a160

Donal.
-- 
Donal Fellows — Tcl user, Tcl maintainer, TIP editor.
0
Donal
5/26/2015 10:17:10 AM
On Tuesday, May 26, 2015 at 11:17:11 AM UTC+1, Donal K. Fellows wrote:
> On 25/05/2015 13:59, phreaman wrote:
> > I wonder if anyone knows something about intentional changes to OO
> > implementation in version 8.6.3 or stumbled upon similar problems
> > using tcl oo extension?
>=20
> This was Bug #b9e1a3032e and unfortunately you were relying on the old
> behaviour. I slipped up and forgot to note in the commit that this was
> an incompatibility with the old system, but it really was wrong.
>=20
> Bug: http://core.tcl.tk/tcl/tktview?name=3Db9e1a3032e
> Fix: http://core.tcl.tk/tcl/info/ab635c816104a160
>=20
> Donal.
> --=20
> Donal Fellows -- Tcl user, Tcl maintainer, TIP editor.

Thanks for the tip. I used oo extension since first beta of TCL 8.6 and sim=
ply assumed that thats the way thinks work ... This bug made modifying exis=
ting code very easy since i could reimplement any method (superclass or mix=
in) defined higher on the hierarchy. =20

0
phreaman
5/27/2015 9:25:49 AM
On 27/05/2015 10:25, phreaman wrote:
> Thanks for the tip. I used oo extension since first beta of TCL 8.6
> and simply assumed that thats the way thinks work ... This bug made
> modifying existing code very easy since i could reimplement any
> method (superclass or mixin) defined higher on the hierarchy.

It was just an error on my part. It happens. :-)

If you want to really *really* override a method, the highest-priority
"normal" method source is an instance-level mixin class that is not used
anywhere else (since methods are sorted to come as late as possible in
the flattening of the inheritance graph). This will override even
instance-level methods:

   % oo::class create Foo {method what {} {puts ==Foo==}}
   ::Foo
   % oo::class create Bar {method what {} {puts ==Bar==}}
   ::Bar
   % Foo create foobar
   ::foobar
   % foobar what
   ==Foo==
   % oo::objdefine foobar method what {} {puts ==foobar==}
   % foobar what
   ==foobar==
   % oo::objdefine foobar mixin Bar
   % foobar what
   ==Bar==

Remember also that there may be multiple mixins defined, both at the
class and the instance level, just as classes may have multiple parent
classes. The order that they are listed in the relevant mixin slot
matters; it's their order of priority within the defined level. Put your
mixin first to ensure it will go first.

Donal.
-- 
Donal Fellows — Tcl user, Tcl maintainer, TIP editor.
0
Donal
6/1/2015 10:59:19 AM
On Monday, June 1, 2015 at 11:59:21 AM UTC+1, Donal K. Fellows wrote:
> On 27/05/2015 10:25, phreaman wrote:
> > Thanks for the tip. I used oo extension since first beta of TCL 8.6
> > and simply assumed that thats the way thinks work ... This bug made
> > modifying existing code very easy since i could reimplement any
> > method (superclass or mixin) defined higher on the hierarchy.
>=20
> It was just an error on my part. It happens. :-)
>=20
> If you want to really *really* override a method, the highest-priority
> "normal" method source is an instance-level mixin class that is not used
> anywhere else (since methods are sorted to come as late as possible in
> the flattening of the inheritance graph). This will override even
> instance-level methods:
>=20
>    % oo::class create Foo {method what {} {puts =3D=3DFoo=3D=3D}}
>    ::Foo
>    % oo::class create Bar {method what {} {puts =3D=3DBar=3D=3D}}
>    ::Bar
>    % Foo create foobar
>    ::foobar
>    % foobar what
>    =3D=3DFoo=3D=3D
>    % oo::objdefine foobar method what {} {puts =3D=3Dfoobar=3D=3D}
>    % foobar what
>    =3D=3Dfoobar=3D=3D
>    % oo::objdefine foobar mixin Bar
>    % foobar what
>    =3D=3DBar=3D=3D
>=20
> Remember also that there may be multiple mixins defined, both at the
> class and the instance level, just as classes may have multiple parent
> classes. The order that they are listed in the relevant mixin slot
> matters; it's their order of priority within the defined level. Put your
> mixin first to ensure it will go first.
>=20
> Donal.
> --=20
> Donal Fellows -- Tcl user, Tcl maintainer, TIP editor.

Lets summarize:=20

Suppose i have class hierarchy like this( <- means order of inheritence):=
=20

ClassA <- ClassB <- ClassC <- ClassD <- ... <- ClassZ=20

and ClassA has some mixin configured, lets name it: someMethodA, and ClassZ=
 has class method with the same name. Then, when i instantiate ClassZ objec=
t and call someMethodA on it, it will first search through all defined mixi=
ns and then search through normal class methods in order of inheritence pro=
ducing something like this.=20

call of ClassA.Mixin.someMethodA
call of ClassZ.someMethodA


Its kind of strange for me that methods from lower levels are called first,=
 but=20
probablly i dont understand concept of mixins ;).  =20

It seems i simply misused the feature never referring to documentation for =
explanation how mixins should be used and what they are for or im just a vi=
ctim of your mistake - just kidding :).

Thanks for the example but i think i will refactor my code to use superclas=
ses instead of mixins since its behaviour is more predictable.

I always liked extensibility and flexibility of TCL language and used it wh=
enever i could. The way mixins now work can be confusing when you deal with=
 big exising codebase (15kloc+).











 =20
0
phreaman
6/1/2015 1:23:37 PM
Having been confused myself (not so much with TclOO as with choosing betwee=
n mixins and inheritance), I tried to articulate my thoughts contrasting th=
e two at http://www.magicsplat.com/articles/oo.html#sect_oo_mixins=20

Perhaps you might find it useful.

/Ashok

On Monday, June 1, 2015 at 6:53:42 PM UTC+5:30, phreaman wrote:
> On Monday, June 1, 2015 at 11:59:21 AM UTC+1, Donal K. Fellows wrote:
> > On 27/05/2015 10:25, phreaman wrote:
> > > Thanks for the tip. I used oo extension since first beta of TCL 8.6
> > > and simply assumed that thats the way thinks work ... This bug made
> > > modifying existing code very easy since i could reimplement any
> > > method (superclass or mixin) defined higher on the hierarchy.
> >=20
> > It was just an error on my part. It happens. :-)
> >=20
> > If you want to really *really* override a method, the highest-priority
> > "normal" method source is an instance-level mixin class that is not use=
d
> > anywhere else (since methods are sorted to come as late as possible in
> > the flattening of the inheritance graph). This will override even
> > instance-level methods:
> >=20
> >    % oo::class create Foo {method what {} {puts =3D=3DFoo=3D=3D}}
> >    ::Foo
> >    % oo::class create Bar {method what {} {puts =3D=3DBar=3D=3D}}
> >    ::Bar
> >    % Foo create foobar
> >    ::foobar
> >    % foobar what
> >    =3D=3DFoo=3D=3D
> >    % oo::objdefine foobar method what {} {puts =3D=3Dfoobar=3D=3D}
> >    % foobar what
> >    =3D=3Dfoobar=3D=3D
> >    % oo::objdefine foobar mixin Bar
> >    % foobar what
> >    =3D=3DBar=3D=3D
> >=20
> > Remember also that there may be multiple mixins defined, both at the
> > class and the instance level, just as classes may have multiple parent
> > classes. The order that they are listed in the relevant mixin slot
> > matters; it's their order of priority within the defined level. Put you=
r
> > mixin first to ensure it will go first.
> >=20
> > Donal.
> > --=20
> > Donal Fellows -- Tcl user, Tcl maintainer, TIP editor.
>=20
> Lets summarize:=20
>=20
> Suppose i have class hierarchy like this( <- means order of inheritence):=
=20
>=20
> ClassA <- ClassB <- ClassC <- ClassD <- ... <- ClassZ=20
>=20
> and ClassA has some mixin configured, lets name it: someMethodA, and Clas=
sZ has class method with the same name. Then, when i instantiate ClassZ obj=
ect and call someMethodA on it, it will first search through all defined mi=
xins and then search through normal class methods in order of inheritence p=
roducing something like this.=20
>=20
> call of ClassA.Mixin.someMethodA
> call of ClassZ.someMethodA
>=20
>=20
> Its kind of strange for me that methods from lower levels are called firs=
t, but=20
> probablly i dont understand concept of mixins ;).  =20
>=20
> It seems i simply misused the feature never referring to documentation fo=
r explanation how mixins should be used and what they are for or im just a =
victim of your mistake - just kidding :).
>=20
> Thanks for the example but i think i will refactor my code to use supercl=
asses instead of mixins since its behaviour is more predictable.
>=20
> I always liked extensibility and flexibility of TCL language and used it =
whenever i could. The way mixins now work can be confusing when you deal wi=
th big exising codebase (15kloc+).
0
palmtcl
6/1/2015 2:29:19 PM
On Monday, June 1, 2015 at 4:29:21 PM UTC+2, pal...@yahoo.com wrote:
> Having been confused myself (not so much with TclOO as with choosing betw=
een mixins and inheritance), I tried to articulate my thoughts contrasting =
the two at http://www.magicsplat.com/articles/oo.html#sect_oo_mixins=20
>=20
> Perhaps you might find it useful.
>=20
> /Ashok
>=20
> On Monday, June 1, 2015 at 6:53:42 PM UTC+5:30, phreaman wrote:
> > On Monday, June 1, 2015 at 11:59:21 AM UTC+1, Donal K. Fellows wrote:
> > > On 27/05/2015 10:25, phreaman wrote:
> > > > Thanks for the tip. I used oo extension since first beta of TCL 8.6
> > > > and simply assumed that thats the way thinks work ... This bug made
> > > > modifying existing code very easy since i could reimplement any
> > > > method (superclass or mixin) defined higher on the hierarchy.
> > >=20
> > > It was just an error on my part. It happens. :-)
> > >=20
> > > If you want to really *really* override a method, the highest-priorit=
y
> > > "normal" method source is an instance-level mixin class that is not u=
sed
> > > anywhere else (since methods are sorted to come as late as possible i=
n
> > > the flattening of the inheritance graph). This will override even
> > > instance-level methods:
> > >=20
> > >    % oo::class create Foo {method what {} {puts =3D=3DFoo=3D=3D}}
> > >    ::Foo
> > >    % oo::class create Bar {method what {} {puts =3D=3DBar=3D=3D}}
> > >    ::Bar
> > >    % Foo create foobar
> > >    ::foobar
> > >    % foobar what
> > >    =3D=3DFoo=3D=3D
> > >    % oo::objdefine foobar method what {} {puts =3D=3Dfoobar=3D=3D}
> > >    % foobar what
> > >    =3D=3Dfoobar=3D=3D
> > >    % oo::objdefine foobar mixin Bar
> > >    % foobar what
> > >    =3D=3DBar=3D=3D
> > >=20
> > > Remember also that there may be multiple mixins defined, both at the
> > > class and the instance level, just as classes may have multiple paren=
t
> > > classes. The order that they are listed in the relevant mixin slot
> > > matters; it's their order of priority within the defined level. Put y=
our
> > > mixin first to ensure it will go first.
> > >=20
> > > Donal.
> > > --=20
> > > Donal Fellows -- Tcl user, Tcl maintainer, TIP editor.
> >=20
> > Lets summarize:=20
> >=20
> > Suppose i have class hierarchy like this( <- means order of inheritence=
):=20
> >=20
> > ClassA <- ClassB <- ClassC <- ClassD <- ... <- ClassZ=20
> >=20
> > and ClassA has some mixin configured, lets name it: someMethodA, and Cl=
assZ has class method with the same name. Then, when i instantiate ClassZ o=
bject and call someMethodA on it, it will first search through all defined =
mixins and then search through normal class methods in order of inheritence=
 producing something like this.=20
> >=20
> > call of ClassA.Mixin.someMethodA
> > call of ClassZ.someMethodA
> >=20
> >=20
> > Its kind of strange for me that methods from lower levels are called fi=
rst, but=20
> > probablly i dont understand concept of mixins ;).  =20
> >=20
> > It seems i simply misused the feature never referring to documentation =
for explanation how mixins should be used and what they are for or im just =
a victim of your mistake - just kidding :).
> >=20
> > Thanks for the example but i think i will refactor my code to use super=
classes instead of mixins since its behaviour is more predictable.
> >=20
> > I always liked extensibility and flexibility of TCL language and used i=
t whenever i could. The way mixins now work can be confusing when you deal =
with big exising codebase (15kloc+).

Thanks, that was really helpful. On the end of the section '6.2. Mixins ver=
sus inheritance' it states:

There is one practical aspect of TclOO design that may drive your decision.=
 Methods implemented via mix-ins appear in the method chain before methods =
defined on the object whereas inherited methods appear after. This was not =
relevant to our example because the mix-in only added new methods. It did n=
ot override exising ones.

You did a great job writing this article, i hope TCL gets more documentatio=
n like this in the future.




0
phreaman
6/2/2015 6:09:58 AM
Reply:

Similar Artilces:

Question on migration from TCL 8.3 to TCL 8.6
Hi All, I am working on a EDA tool which is built on TCL 8.3 platform. I need to upgrade the platform to TCL 8.6. Is it proper to move directly from 8.3 to 8.6 version? Or should I upgrade to TCL 8.5 as TCL 8.6 is still beta version. Please suggest me precautions. Please point me to documentation/User guide related to this. Thanks for help, Divyesh On Thursday, 30 January 2014 04:47:57 UTC, Divyesh Patel wrote: > Is it proper to move directly from 8.3 to 8.6 version? Or should I upgrade to TCL 8.5 as TCL 8.6 is still beta version. > Tcl 8.6.1 is now the current ...

Re: Alpha object file changes
sms@antinode.org (Steven M. Schweda) wrote on 10/03/2006 01:45:28 PM: > From: "Don" <nospam@dgcomputer.com> > > > ftp did in fact munge my object module, even with binary transfer. I > > ended up ftping a save set and unpacking it. Even then, the save set > > file attributes needed to be reset. > > Zip -V (before) and UnZip (after the binary FTP transfer) can save > much fooling around with file attributes. or without case-sensitive command lines: ZIP "-V" (before). > > ---------------------------------------------------...

Tcl/Tk 8.6.3, Itcl 4.0.2, sqlite 3.8.7 Release Candidates
Release candidate downloads of the 8.6.3 releases of Tcl and Tk, Itcl 4.0.2, and sqlite 3.8.7 may now be found at https://sourceforge.net/projects/tcl/files/Tcl/8.6.3/ The actual releases of these files should come on October 29. Until then, enjoy this advance preview, and if you find anything catastrophically wrong with them, please inform me so we can fix the problem before the true release. -- | Don Porter Applied and Computational Mathematics Division | | donald.porter@nist.gov Information Technology Laboratory | | http://math.nist.gov/~DPorter/...

Re: Alpha object file changes
From: "Don" <nospam@dgcomputer.com> > ftp did in fact munge my object module, even with binary transfer. I > ended up ftping a save set and unpacking it. Even then, the save set > file attributes needed to be reset. Zip -V (before) and UnZip (after the binary FTP transfer) can save much fooling around with file attributes. ------------------------------------------------------------------------ Steven M. Schweda sms@antinode-org 382 South Warwick Street (+1) 651-699-9818 Saint Paul MN 55105-2547 ...

Alpha object file changes
I have an object file created using "Compaq C V6.5-001 on OpenVMS Alpha V6.2-1H3". I just tried to copy and use it on a new Alpha system running OpenVMS v8.2. The linker did not like the .OBJ file. Analyze/obj recognized the file as an OpenVMS Alpha object module, but found multiple errors. Is there any way to "fix" this object module?? The project I'm working on is late / over-budget (aren't they all?). Buying a C license for the new Alpha is probably not in the cards. Thanks for the help, Don Gregg "Don" <nospam@dgcomputer.com> wrote in ...

Re: Alpha object file changes
From: "Don" <nospam@dgcomputer.com> > I have an object file created using "Compaq C V6.5-001 on OpenVMS Alpha > V6.2-1H3". I just tried to copy and use it on a new Alpha system > running OpenVMS v8.2. The linker did not like the .OBJ file. "tried to copy" how? Alpha object files are "Record format: Variable length" files, and those attributes may be altered/lost in a number of ways. VMS V6.2-1H3 is plenty old, but I don't recall any change to the object file format. DIRECTORY /FULL before and after might be informative. &...

Re: Alpha object file changes
From: norm.raphael@metso.com > > Zip -V (before) and UnZip (after the binary FTP transfer) can save > > much fooling around with file attributes. > > or without case-sensitive command lines: > ZIP "-V" (before). Yes, I suppose at VMS V6.2, there's not much chance of SET PROCESS /PARSE_STYLE = EXTENDED working, so "-V" would need to be quoted there. "Zip -h" is suggestive: [...] Zip 2.32 (June 19th 2006). Usage: zip=="$disk:[dir]zip.exe" [...] "-V" save VMS file attributes ("-VV" also save allocate...

Bug789040 came back in Tcl 8.4.6 and Tcl 8.5.
Dear All, Bug 789040 caused exec error in Windows 9x and was fixed in 10/04/03. But it came back in Tcl 8.4.6 and Tcl 8.5. Tcl Windows 9x users should be alerted to the possible failure of exec in the current Tcl 8.4.6 and 8.5 releases due to this bug. Chengye Mao http://www.geocities.com/~chengye Chengye Mao wrote: > Bug 789040 caused exec error in Windows 9x and was fixed in 10/04/03. > But it came back in Tcl 8.4.6 and Tcl 8.5. Tcl Windows 9x users > should be alerted to the possible failure of exec in the current Tcl > 8.4.6 and 8.5 releases due to this bug. Have you i...

ANNOUNCE: freeWrap 8.6 released (supports TCL/TK 8.6.0)
This message announces the availability of freeWrap version 6.6. FreeWrap 6.6 is based on TCL/TK 8.6.0 freeWrap is a program that allows creation of stand-alone TCL/TK executables without needing a compiler. Versions are free and available for the Windows and Linux operating systems. Instructions and source code for building freeWrap are also available. The following additional variation of freeWrap is also available for download: freewrapTCLSH a console-only application which includes only TCL. Please visit the freeWrap home page: http://freewrap....

Tcl 8.6, ActiveTcl 8.6 & linux Fedora 16 (64 bit)...
Hi all, Just a quick note about installing ActiveTcl 8.6 under Fedora 16, 64 bit. Downloading ActiveTcl 8.6 and trying to run the installer, fails. The reason is that libXss.so, is missing from the system, and Tk seems to need this. The problem can be "resolved" by installing the package "libXScrnSaver". But there is no such package for Fedora 16, and (thankfully) the package gets installed from Fedora 15. Maybe this is a "sign" that libXss.so will disappear in the (near?) future... George PS: Also the mysql TDBC driver crashes, as the shared library has ...

Re: TeXForm: slight change in behaviour from version 7 to version 8 #2
This looks like it may be related to the problem reported at: <URL:https://groups.google.com/d/msg/comp.soft-sys.math.mathematica/pGn9by54efA/FNQ33z-ZNFIJ> fwiw, Alan ...

Re: TeXForm: slight change in behaviour from version 7 to version 8 #3
Hi Phil, You may want to contact Wolfram support with this question. Themis ...

Defect: std::endl in (a) 22.2.8/5, (b) 22.2.8/11, (c) 22.2.8/13, (d) 27.6.1.3/22
std::endl is declared by <ostream>, which is not necessarily included by <iostream>. The cited paragraps, (a) 22.2.8/5, (b) 22.2.8/11, (c) 22.2.8/13 and (d) 27.6.1.3/22, contain program examples that use std::endl without including <ostream>, just <iostream>, and even though the unofficial revision list for C++2003 contains a fix for e.g. 22.2.8/11 this issue has not been fixed there (I don't have the C++2003 standard). My suggested resolution is to keep the examples as-is but ensure that the declaration of std::endl is available via <iostream>, si...

version 6 AI in version 8
I am trying to create modify a VI that was created using labview v6.0.&nbsp; I am modifying it in 8.0.&nbsp; The old program uses the Analogue input VI called 'AI Acquire Waveforms'&nbsp; I just uses a device number with the appropriate count, rate and other settings.&nbsp; Instead I want to use a VI in&nbsp;the Universal Library for LabView&nbsp;with version 8.0 program.&nbsp; The VI I specifically want to use is called AI Sc Fgd i think.&nbsp; Same sort of idea, uses a 'Board number' instead of device number.&nbsp; The main difference is th...

Web resources about - Tcl OO mixins and inheritence behaviour change from version 8.6.2 to version 8.6.3 - comp.lang.tcl

Senior Couple’s Marriage Questioned Because It Might Change Daughter’s Inheritence
Edith Hill, 96, and Eddie Harrison, 95, met over a decade ago while standing in line to buy lottery tickets – one of which turned out to be a ...

Inheritence and Invention: Flannery O’Connor’s Prayer Journal
O’Connor’s prayer journal will be of interest not only to those who know her work but to anyone who writes.

Members Only (The Sopranos) - Wikipedia, the free encyclopedia
" Members Only " is the sixty-sixth episode of the HBO series The Sopranos , and the first of the show's sixth season. Written by Terence Winter ...

FMG facing debt crisis
Listen and watch live talk back radio portal, gathering national and local news in Australia. 6PR, 3AW, 6PR and 4BC. Come and have your say, ...

Canberra can't blame Menzies, or Abbott, for asbestos
Blowed if I can discover the moral or legal case why the taxpayer should pay for the removal of 40 to 50-year-old asbestos.

Tax Reform Australia
A tax or duty is a compulsory charge imposed on an individual or legal entity by a government or equivalent. In Australia taxes and duties are ...

Ask Noel
Noel Whittaker answers your questions on inheritence tax, capital gains tax and more.

Victorian Gay & Lesbian Rights Lobby - Contact
Victorian GLBTIQ Rights Lobby. Equality and Social Justice for the whole community.

AdaptCMS - Features - Content Management System
AdaptCMS is an open source Content Management System that is made for complete control of your website, easiness of use and adaptable to any ...

Google isn’t Evil. Flash isn’t Dead; Thank god the Open Web doesn’t have a single vendor
Steve Jobs didn’t hold back when talking about Google and Adobe . That is great. Life is so much more fun when people speak their mind. I remember ...

Resources last updated: 1/25/2016 3:23:06 PM