|
Methods
Semantics of method-calls, best practices, and possible future modifications.
Featured In ECT 0.2General method callsSyntax{Object}:methodname(Arg1, Arg2, ..., ArgN)ResultThe exact result is only determined at run-time:
Superclass method callsSyntaxOnly usable in modules that define a class, and this class has a superclass. {{Object}}:methodname(Arg1, Arg2, ..., ArgN)ResultSimilar to super.methodname(Arg1, Arg2, ..., ArgN) in Java. The call is executed like in the previous case, but with the bold italic text omitted from step 1. Return value conventionsThis is not so nice, but I the following things seem to be a good practice: When a method does not affect fields of the objectReturn any value you like. For example: clever_method(This = #example{field1 = A}, B) ->
A+B.When a method does affect fields of the objectReturn the updates version of the object: clever_method(This = #example{field1 = A}, B) ->
This#example{field1 = A+B}.When a method does affect fields of the object, and returns a valueReturn a tuple with the updates version of the object and with the calculated value: genious_method(This = #example{field1 = A}, B) ->
{This#example{field1 = A+B}, A*B}.In ECT 0.3+ - possible future modificationsGeneral method callsObject:methodname(Arg1, Arg2, ..., ArgN) Issues:
Superclass method calls... |
► Sign in to add a comment