[Xotcl] Passing a switch non-positional argument

Gustaf Neumann neumann at wu-wien.ac.at
Thu Mar 2 02:32:56 CET 2006


Kurt,

passing around the actual values of the non-positional arguments
with next or with a forwarder is already very conveniant, but this
was not your question.

Passing unary non-pos arguments to some explicit method invocations
is some typing work, but straightforward. Passing a switch is painful.
Your example can be made somewhat shorter

    eval my p1 [expr {$sw? "-sw" : ""}] [list -opt $opt]

list is needed to protect the value of opt, if it contains e.g.
a $, spaces etc. But still, the preceding eval reminds me on the days
of otcl and does not win a beauty contest.

For your example, i would tend to use boolean non-pos-args instead.
We introduced the 0-argument switch mostly for oacs, which
uses a similar construct already for it's ad_proc. When one defines
in xotcl a public/private method with boolean, as in

   SomeClass method -private true foo {x y } ....

this looks rather stupid compared to

   SomeClass method -private  foo {x y } ....

However, in many other situations, the notation with
the boolean argument as in

   obj -someflag on

or

  obj -debug true

looks from the aesthetical point of  view quite  ok to me.

-gustaf neumann
 



More information about the Xotcl mailing list