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

Re: [Xotcl] Passing a switch non-positional argument

From: Gustaf Neumann <>
Date: Thu, 02 Mar 2006 02:32:56 +0100


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


  obj -debug true

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

-gustaf neumann