[Xotcl] Problem With Forwarding Defaults

Gustaf Neumann neumann at wu-wien.ac.at
Mon Sep 20 23:04:39 CEST 2004


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



More information about the Xotcl mailing list