[Xotcl] Send NULL arg to Class constructor
Ross, Colin
colross at CROSSBEAMSYS.COM
Tue Apr 28 02:14:06 CEST 2009
Hi Gustaf - thanks so much for your prompt response. The "instproc configure" is perfect for what I need to do. I do appologise for not being able to find it in the documentation - I guess if you dont know what you are looking for then its difficult to find it.
Thanks again.
Cheers
Colin
-----Original Message-----
From: Gustaf Neumann [mailto:neumann at wu-wien.ac.at]
Sent: Mon 4/27/2009 7:24 PM
To: Ross, Colin
Cc: xotcl at alice.wu-wien.ac.at
Subject: Re: [Xotcl] Send NULL arg to Class constructor
Colin Ross schrieb:
>
> 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
>
One can call arbitrary methods via configure. You just have just to provide
your own method to handle such a cases, as the default parameter handling
expect always exactly one argument.
==========================
::xotcl::Class Connect -parameter {
{ssh}
{ip}
}
Connect instproc telnet {} {
my set telnet true
}
Connect instproc init {node args} {
my instvar telnet ip
# provide a default
if {![info exists telnet]} {
set telnet false
}
puts telnet=$telnet
# ....
}
Connect dev node -ip "127.0.0.1" -telnet
==========================
> 1. Prevent the constructor parsing args so that I can parse my own
>
This is as well an option:
==========================
::xotcl::Class Connect
Connect instproc configure args {
#
puts stderr "wanna interpret $args"
#
# do what ever you want to do with the arguments.....
#
}
Connect dev node -ip "127.0.0.1" -telnet
==========================
All the best
-gustaf neumann
More information about the Xotcl
mailing list