[Xotcl] Send NULL arg to Class constructor

Gustaf Neumann neumann at wu-wien.ac.at
Tue Apr 28 01:24:42 CEST 2009


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