ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> tcl-core
tcl-core
Re: [TCLCORE] Pre-CFV: TIP#257
by Arnulf Wiedemann other posts by this author
May 7 2008 12:11AM messages near this date
Re: [TCLCORE] enhanced oo variables followup TIP; schedule | Re: [TCLCORE] Pre-CFV: TIP#257
Am Mittwoch, 7. Mai 2008 03:09:56 schrieb Will Duquette:
>  On May 6, 2008, at 2:37 AM, Donal K. Fellows wrote:
>  > Ah, the "public vs private" state issue. Other languages get
>  > themselves
>  > in a proper tangle over this, so I know we have to treat carefully.
>  >
>  > As a matter of principle, I don't want to have state that the object
>  > can't inspect on itself; I think that that would be un-Tclish.
> 
>  This I agree with; and Snit doesn't implement "private" state as such.
>  (Of course, you don't get inheritance, either, so in a sense all
>  instance variables are private by default; but that's happenstance.)
> 
>  > That in
>  > turn means that I'm inclined to say that if two classes use the same
>  > variable name, they get the same variable (which greatly reduces the
>  > complexity of the implementation).
> 
>  This I think would be a big mistake, as it makes it to easy for changes
>  to superclass A (possibly written by developer B and included in package
>  C) to break subclass D, written by application developer E.  Trevor
>  suggests we protect against this by using a naming convention for
>  instance variables, to which I can only say "Ugh!"  Isn't that what
>  namespaces are for?
> 
>  Itcl has a solution that allows public variables defined by a class
>  and its ancestors to be shared without name collisions; and Arnulf
>  has already written a variable resolver for TclOO that implements it.
>  I suggest we adopt it for TclOO in general.
> 
>  Will

just to make it easier to discuss about that area, I will describe my current 
way to solve the problem, also I am not yet really happy with that solution 
yet:

here is an example (not fully itcl syntax!)

class animal 
   private variable priv  priv_animal
   protected variabled prov_animal
   public variable pubv pub_animal
   protected variable prov_animal_only prov_animal_only

   public method show_animal_vars {} { 
      puts "priv!$priv!prov!$prov!pubv!$pubv!prov_animal_only!
$prov_animal_only!" 
   }

class cat
  inherit animal
  private variable priv priv_cat
  protected variable prov prov_cat
  public variable pubv pub_cat
  # prov_animal_only is also usable here !!

   public method show_cat_vars {} { 
      puts "priv!$priv!prov!$prov!pubv!$pubv!prov_animal_only!
$prov_animal_only!" 
   }

cat leo ; # creates object leo

leo show_animal_vars produces: 
priv!priv_animal!prov!prov_animal!pubv!pubv_animal!prov_animal_only!prov_animal_only!

leo show_cat_vars produces: 
priv!priv_cat!prov!prov_cat!pubv!pubv_cat!prov_animal_only!prov_animal_only!
 

And here is what I am doing in itcl-ng:

In itcl-ng I create a namespace leo for the object leo (which is also a 
command!). Within namespace leo there is a namespace for every class of the 
object

leo
  animal
  cat

the variables are in these namespaces and are "mapped" using the namespace 
resolver

leo
  animal
     priv
     prov
     pubv
     prov_animal_only
  cat
     priv
     prov
     pubv

That is working, but I am not very happy with it. What I would like to have is 
some construct like this or similar in Tcl core with fast access, as creation 
of that structure takes a lot of time at the moment, when creating the 
object. Would be also useful, if there would be support for optional (for the 
extensions which need it) checking of the protection/storage class 

Arnulf


Arnulf
> 
> 
> 
>  ------------------------------------------------------------------
>          will -at- wjduquette.com      | Catch our weblog,
>  http://foothills.wjduquette.com/blog | The View from the Foothills
> 
> 
> 
>  -------------------------------------------------------------------------
>  This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>  Don't miss this year's exciting event. There's still time to save $100.
>  Use priority code J8TL2D2.
>  http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/java
> one _______________________________________________
>  Tcl-Core mailing list
>  Tcl-Core@[...].net
>  https://lists.sourceforge.net/lists/listinfo/tcl-core



-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Tcl-Core mailing list
Tcl-Core@[...].net
https://lists.sourceforge.net/lists/listinfo/tcl-core
Thread:
Twylite
Will Duquette
Kevin Kenny
Kevin Kenny
Will Duquette
Arnulf Wiedemann
Will Duquette
Kevin Kenny
Donal K. Fellows
Twylite
Larry W. Virden
Twylite
Gustaf Neumann
Larry McVoy
Gerald W. Lester
Vasiljevic Zoran
Larry McVoy
Gerald W. Lester
Larry McVoy
Tomasz Kosiak
Gustaf Neumann
Donal K. Fellows
Daniel A. Steffen
Donal K. Fellows
Daniel A. Steffen
Donal K. Fellows
Donal K. Fellows
Daniel A. Steffen
Gerald W. Lester
Vasiljevic Zoran
Arnulf Wiedemann
Tom Krehbiel
Vasiljevic Zoran
Donal K. Fellows
Gustaf Neumann
Brian Griffin
Gustaf Neumann
Donal K. Fellows
Gustaf Neumann
Kristoffer Lawson
Daniel A. Steffen
Twylite
Donal K. Fellows
Will Duquette
Donal K. Fellows
Will Duquette
Arnulf Wiedemann
dgp
Donal K. Fellows
Arnulf Wiedemann
Twylite
Will Duquette
Twylite
Donal K. Fellows
Stefan Sobernig
Donal K. Fellows
Stefan Sobernig

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved