seems a strange way to delete a SWIG'd object 
Author Message
 seems a strange way to delete a SWIG'd object

I really like SWIG!  It's amazing how much of a leg up it gives you in wrapping
up C and C++ code.  I've wrapped a class with SWIG and am thrilled to be able to
do:

    set s [myClass]

in Tcl to parallel C++'s:

    myClass* s = new myClass;

But I'm bothered that C++'s:

    delete s;

doesn't have a parallel in Tcl.  Somehow

    rename $s ""

just doesn't say what I mean.  In Tk you do:

    set b [button ....]
    ...
    destroy $b

With SWIG and my classes, I'd like a "done" or "destroy" or something.  Granted,
I can write:

    proc done { p } {
        rename $p ""
    }

but something "standard" would be nicer, I think.  Any thoughts?

                                            Chris
--
Rens-se-LEER is a county.  RENS-se-ler is a city.  R-P-I is a school!



Fri, 17 Jan 2003 03:00:00 GMT  
 seems a strange way to delete a SWIG'd object

Quote:

> I really like SWIG!  It's amazing how much of a leg up it gives you in wrapping
> up C and C++ code.  I've wrapped a class with SWIG and am thrilled to be able to
> do:

>     set s [myClass]

> in Tcl to parallel C++'s:

>     myClass* s = new myClass;

> But I'm bothered that C++'s:

>     delete s;

> doesn't have a parallel in Tcl.  Somehow

>     rename $s ""

> just doesn't say what I mean.  In Tk you do:

>     set b [button ....]
>     ...
>     destroy $b

> With SWIG and my classes, I'd like a "done" or "destroy" or something.  Granted,
> I can write:

>     proc done { p } {
>         rename $p ""
>     }

> but something "standard" would be nicer, I think.  Any thoughts?

Does "unset" work? I don't know SWIG, but the inverse to "set" is "unset".

Quote:

>                                             Chris
> --
> Rens-se-LEER is a county.  RENS-se-ler is a city.  R-P-I is a school!

--
http://home.att.net/~lcargill


Sat, 18 Jan 2003 03:00:00 GMT  
 seems a strange way to delete a SWIG'd object

Quote:


> > I really like SWIG!  It's amazing how much of a leg up it gives you in wrapping
> > up C and C++ code.  I've wrapped a class with SWIG and am thrilled to be able to
> > do:

> >     set s [myClass]

> > in Tcl to parallel C++'s:

> >     myClass* s = new myClass;

> > But I'm bothered that C++'s:

> >     delete s;

> > doesn't have a parallel in Tcl.  Somehow

> >     rename $s ""

> > just doesn't say what I mean.  In Tk you do:

> >     set b [button ....]
> >     ...
> >     destroy $b

> > With SWIG and my classes, I'd like a "done" or "destroy" or something.  Granted,
> > I can write:

> >     proc done { p } {
> >         rename $p ""
> >     }

> > but something "standard" would be nicer, I think.  Any thoughts?

> Does "unset" work? I don't know SWIG, but the inverse to "set" is "unset".

Unfortunately SWIG objects are commands which have to be explicitly
deleted.


Sat, 18 Jan 2003 03:00:00 GMT  
 seems a strange way to delete a SWIG'd object

Quote:

> I really like SWIG!  It's amazing how much of a leg up it gives you in wrapping
> up C and C++ code.  I've wrapped a class with SWIG and am thrilled to be able to
> do:

>     set s [myClass]

> in Tcl to parallel C++'s:

>     myClass* s = new myClass;

> But I'm bothered that C++'s:

>     delete s;

> doesn't have a parallel in Tcl.  Somehow

>     rename $s ""

> just doesn't say what I mean.  In Tk you do:

>     set b [button ....]
>     ...
>     destroy $b

> With SWIG and my classes, I'd like a "done" or "destroy" or something.  Granted,
> I can write:

>     proc done { p } {
>         rename $p ""
>     }

> but something "standard" would be nicer, I think.  Any thoughts?

Is [rename $s ""] the way which SWIG tells you to do it ? If so it is
a standard of sorts.

I agree that it would be nice to be able to use a better command to
do it.
e.g.
        proc delete {args} {
            foreach a $args {
                catch {rename $a ""}
            }
        }



Sat, 18 Jan 2003 03:00:00 GMT  
 seems a strange way to delete a SWIG'd object

Quote:

> I really like SWIG!  It's amazing how much of a leg up it gives you in wrapping
> up C and C++ code.  I've wrapped a class with SWIG and am thrilled to be able to
> do:
>     set s [myClass]
> in Tcl to parallel C++'s:
>     myClass* s = new myClass;
> But I'm bothered that C++'s:
>     delete s;
> doesn't have a parallel in Tcl.  Somehow
>     rename $s ""
> just doesn't say what I mean.  

Well, SWIG is creating a new command, and renaming a command to "" is
the "Tcl Way" to delete a command.  

Bob
--

Mayo Foundation                                           (507) 284-2702
Rochester MN, 55905 USA   http://www.mayo.edu/sppdg/sppdg_home_page.html



Sat, 18 Jan 2003 03:00:00 GMT  
 seems a strange way to delete a SWIG'd object


:Well, SWIG is creating a new command, and renaming a command to "" is
:the "Tcl Way" to delete a command.  

So then it is Tk that is not doing things the Tcl Way, by including a
destroy command?

Seems to me that the Tcl Way, in this case, is too obscure ...

--
<URL: https://secure.paypal.com/refer/pal=lvirden%40yahoo.com>

Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.



Mon, 20 Jan 2003 03:00:00 GMT  
 seems a strange way to delete a SWIG'd object

Quote:


> :Well, SWIG is creating a new command, and renaming a command to "" is
> :the "Tcl Way" to delete a command.

> So then it is Tk that is not doing things the Tcl Way, by including a
> destroy command?

> Seems to me that the Tcl Way, in this case, is too obscure ...

Now that you mention it... [rename xyzzy ""] is a little obscure.  Incr
Tcl provides a [delete] command.  Hmmm.  Sounds like another Tcl 9.0
argument in the making. :-)

Bob
--

Mayo Foundation                                           (507) 284-2702
Rochester MN, 55905 USA   http://www.mayo.edu/sppdg/sppdg_home_page.html



Mon, 20 Jan 2003 03:00:00 GMT  
 seems a strange way to delete a SWIG'd object
Quote:

> Now that you mention it... [rename xyzzy ""] is a little obscure.  Incr
> Tcl provides a [delete] command.  Hmmm.  Sounds like another Tcl 9.0
> argument in the making. :-)

In the spirit of recent discussions, "delete" would be too generic.
Better call it "proc delete". But then "proc" must also be extended -
just to make each and every piece of Tcl code on earth break ;-)
Of course it would be tidy to have
        proc create name body
        proc rename name1 name2
        proc names (ex info proc)
        proc delete
        proc body name (ex info body)
        proc args, proc defaults ...
Maybe in Tcl 10.0?
--
Schoene Gruesse/best regards, Richard Suchenwirth - +49-7531-86 2703
RC DT2, Siemens Electrocom, Buecklestr. 1-5, D-78467 Konstanz,Germany
-------------- http://purl.org/thecliff/tcl/wiki//Richard*Suchenwirth
AL:The Analytical Engine worketh not! CB:What version dost thou have?


Mon, 20 Jan 2003 03:00:00 GMT  
 seems a strange way to delete a SWIG'd object

Quote:

> So then it is Tk that is not doing things the Tcl Way, by including a
> destroy command?

Renaming the widget procedure to the empty string works too.  This
means that all you need to do is to extend [destroy] to work with any
command, and not just Tk widgets.  It would even be (pretty much)
backward-compatible...

Donal.
--

-- I may seem more arrogant, but I think that's just because you didn't
   realize how arrogant I was before.  :^)



Tue, 21 Jan 2003 03:00:00 GMT  
 seems a strange way to delete a SWIG'd object

Quote:

> > So then it is Tk that is not doing things the Tcl Way, by including a
> > destroy command?

> Renaming the widget procedure to the empty string works too.  This
> means that all you need to do is to extend [destroy] to work with any
> command, and not just Tk widgets.  It would even be (pretty much)
> backward-compatible...

The "Tcl Way" is pretty much meaningless in this area.  Consider the
variety of ways to delete things in Tcl/Tk alone:

rename proc ""
unset var
destroy .widget
close channel
after cancel id
bind tag ""
file delete filename
(there's probably more)

Anyway, the rename thing is dumb, and not surprisingly, nothing else
uses that model, and it certainly should not be used as a model for
other destructors.



Tue, 21 Jan 2003 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Something strange with 'object'

2. seems to delete the file(?)

3. This may seem a slightly strange problem ...

4. expect's full_buffer doesn't seem to work

5. List of objects sorted in multiple ways

6. (Second try) Query: other ways to implement encapsulated objects

7. Totally Objects News Server seems to be visible

8. Strange Delete Problem

9. strange delete key experience

10. Strange behaviur when deleting record - repost

11. Strange behaviour - delete record

12. Here are 3 ways to get window on top that didn't work for me

 

 
Powered by phpBB® Forum Software