Re: can you return an object from a proc?



googlegro...@xxxxxxxxxxxxxxx wrote:
This is not how most other object oriented languages
operate. They have constructors and destructors. When you
create an object in java, or c++, you are returned
a reference (normally a word sized address) which you
then use to manipulate the object. Tcl does this for
some objects, like opened files or sockets. But other
objects, like yours and like widgets, you have to provide
a unique text string to reference the object, and the
object creation call uses that string to reference the
object, AND creates a command of the same name that you
then use to manipulate the object.

This sort of thing is why many OO systems for Tcl allow you to create
objects with either explicit names or with an automatically-chosen
unique name. (And you know what? Each is the right thing to do in some
cases.) If you can't do that, it's not that hard to implement a system
that uses sequence numbers as part of the names you have to provide.

Donal.
.



Relevant Pages

  • Re: Larry Wall, on Tcl
    ... extensions written in something other than Tcl, ... I've been trying to identify a problem with using Tcl that garbage ... the only kind of reference ... TCL allows is a rather flimsy string token. ...
    (comp.lang.tcl)
  • Re: Shortcut menus and VBA
    ... Once I have set references to "YourotherControl" which is a sub menu called ... how do I Add or Delete the required controls? ... > Is this an Access application you're trying to manipulate, ... you'll have to have a reference set to the Office ...
    (microsoft.public.access.modulesdaovba)
  • Re: Creating object from type
    ... If you want to manipulate the dynamically created objects, ... have reference to them. ... > Is there any way to get a type of object from a string. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Pass by reference or value?
    ... The method or constructor can *always* manipulate any object it ... String or other so-called immutable classes; ... There are other immutable classes as well as String, ... a new reference to the object is created and put on the ...
    (comp.lang.java.programmer)
  • Re: A valid question?
    ... > private void do{ ... reference "this" refers to it, ... each is just a reference to an object, and the accessibility ... references and uses them to manipulate the objects. ...
    (comp.lang.java.programmer)