Water 5-Method and Class-Water Contract | Water 5-Method and Class-Water Contract
method call
Contract
Return typewob
Parameter keyDefault valueType
a_objectreq
args<thing/>expression_call
a_context<java_object/>expression_call
subjectopt
Water Contract
<method call
  a_object =req
  args     =<thing/>

  a_context=<context/>

  subject  =opt/>

See also: execute, execute_string

Call is a method to perform calls programmatically. It is an advanced feature not needed for most uses. The subject of the call can be passed in either as an explicit argument of _subject , or as the left hand subject to the call of call itself. The first argument is the "method" or the class of the object to be constructed. If it is a string, it is taken to be the name of the method or object within the subject. The second argument is an object containing the args to pass to the method. This can be a vector, in which case all arguments are "by position". You can also use a record as the value of the second argument. The unnumbered non-system fields will be used to pass args by key, with the key being the key of the field and the value being the value passed in. the numbered field of the record (in which case you'll have a 'supervector'), will be the by-position arguments. With call you can pass arguments by-position as well as by key. All of the arguments to call are executed, then the actual call is made with those values. Given a definition of:
<method thing.foo89 boo=req bar=req baz=req> 
       <join boo " " bar " " baz/> 
     </>
<call "foo89" <vector 10 20 30/> _subject=thing/>
"10 20 30"
is equivalent to:
thing.<foo89 10 20 30/>"10 20 30"
thing.<call thing.foo89 <thing boo=10 bar=20 baz=30/> />
"10 20 30"
is equivalent to:
thing.<foo89 boo=10 bar=20 baz=30/>
"10 20 30"
thing.<call thing.foo89 <thing _unkeyed_args=<v 10 20/> baz=30 /> />
"10 20 30"
is equivalent to:
thing.<foo89 10 20 baz=30/>"10 20 30"
If the method takes _vector_fields arguments, then the same rules apply as to how the arguments are mapped to the parameters as will normal calls, i.e. First all the keyed arguments are mapped to the same-named parameters, then the first arguments are applied to all the required arguments of the method, finally the remainder of the by-position arguments are used for _vector_fields args. As usual in calls, if _vector_fields args are permitted, then no by-position args get mapped to optional parameters. Constructing new instances of a class works similarly:
<call <class thing.boat weight=req/> <vector 241/> />
<thing.boat weight=241/>
The context arg can take a record or a context just like execute_string