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

Re: [Xotcl] Problem With Forwarding Defaults

From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Mon, 20 Sep 2004 23:04:39 +0200

On Monday 20 September 2004 17:33, MichaelL_at_frogware.com wrote:
> I have a class I use to manage collections of aggregated objects. I'm
> trying to use it with the -Class parameter option and instforwarding so
> that I can do things like this:
>
> Test x
> x apples add Z
> x apples items
>
> *That* part I can get to work as expected. But I can't get the default
> option of instforwarding to work for this case:
>
> x apples

Michael,

the default values are only used in te substitution of %1,
which refers to the first argument of the invocation. The
default ist used, whenever the argument is not specified
in the invocation. So, essentially, the %1 was missing
in your example (see below)

best regards
-gustaf

=================================

  Test instforward apples -default {items add} {%my _apples_} %1
  Test instforward oranges -default {items add} {%my _oranges_} %1

  Test z
  z apples new TestItem
  z apples new TestItem

  # no arguments, use default
  puts [z apples]

  Class GoldenDelicious
  GoldenDelicious apple1
  GoldenDelicious apple2

  # explicit add
  z apples add apple1

  # implcit add (via default)
  z apples apple2

 puts [z apples]
=================================

-- 
Univ.Prof. Dr.Gustaf Neumann
Abteilung für Wirtschaftsinformatik und Neue Medien
Wirtschaftsuniversität Wien, Augasse 2-6, 1090 Wien