Water 5-Method and Class-Class
method make
Contract
Return typewob
No input parameters.
Water Contract
<method make/>

See also: class, cache_instance

When you create an instance of a class, say <boat weight=123/> a new object is made with a _parent field whose value is boat and a wieght field whose value is 123. By default that object is returned from the call to boat. However, if you'd like to modify the fields of boat when it is created or would like a call to return something other than the instance that is created, then you should define a make method on that class. The make method takes no arguments. The _subject of the make method is the new instance that has been created with its _parent field and any other fields in the call initialized. Fields that have default values are not added to the new instance but they will be inherited from the class. In the body of the make method you can add fields, remove fields, modify field values, do any side effects you want and finally return anything you want. Be careful on what is returned as normally the _subject should returned.
<class boat weight=123>
  <method make>
    <if> .weight.<is 123/> .<set weight=999/> </if>
    .<set color="blue"/>
    _subject
  </method>
 </class>
  <boat 123/>.weight
999
If you'd like to "cache" the instance, call cache_instance from within make . More docmentation on make in the context of class is available in the class documentation.

_other_keyed and _other_unkeyed

These parameters in a call to class behave similarly as they do in calls to method. One minor difference is that for _other_keyed, the "name" in the 5th parameter characteristic position defaults to "add_to_environment". This means to add it to the class being made. Here we define truck to be able to take ANY fields hwen an instance is made. So our call <truck wheels=4 engine="V8"/> doesn't error even though we haven't mentioned wheels and engine in the class definition. They just show up as fields in the returned instance that is created.
<class truck _other_keyed=opt/>
<truck wheels=4 engine="V8"/>.engine
"V8"