View · Search · Index
No registered users in community xowiki
in last 10 minutes

[Xotcl] Send NULL arg to Class constructor

From: Colin Ross <colross_at_CROSSBEAMSYS.COM>
Date: Mon, 27 Apr 2009 17:44:12 -0400

Hi all ­ I have ported over one of our applications from using itcl to using
xotcl. I have a lot of code that already uses the itcl stuff, so the port
must be backwards compatible. I have the following issue. Can anyone give me
an idea how I can get around it? A script that shows my issue is as follows:

#!/usr/bin/tclsh
package req XOTcl
namespace import ::xotcl::*

::xotcl::Class Connect -parameter {
    {telnet}
    {ssh}
    {ip}
}
Connect instproc init {node args} {
    [self] instvar telnet
    [self] instvar ip
}

Connect dev node -ip "127.0.0.1" -telnet

The above does not work, as it seems that the ­telnet arg must not be NULL,
however, I need this to be NULL, as it is just a flag.

If I pass in:
Connect dev node -ip "127.0.0.1" -telnet ³²

This works, however, this is not backwards compatible with how things were
with itcl, and I have too many users/scripts to change how this is done.
There are potentially 2 ways around this, however, I am unable to find
information on if either of them are possible:
1. Allow the passing in of a NULL argument
2. Prevent the constructor parsing args so that I can parse my own


I would appreciate any assistance

Cheers
Colin