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

Re: [Xotcl] Send NULL arg to Class constructor

From: Ross, Colin <colross_at_CROSSBEAMSYS.COM>
Date: Mon, 27 Apr 2009 20:14:06 -0400

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