No registered users in community xowiki
in last 10 minutes
in last 10 minutes
Re: [Xotcl] Send NULL arg to Class constructor
From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Tue, 28 Apr 2009 01:24:42 +0200
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
Date: Tue, 28 Apr 2009 01:24:42 +0200
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