CBFalconer wrote:
My own attitude is that the use of result is pointless in the first place. It gains nothing that I can see over the standard method "bar := ...". In fact I like to code many things as:
FUNCTION foo : T
VAR anotherTvalue : T BEGIN foo := someTvalue; (* default *) .... IF whatever THEN foo := anotherTvalue; .... END;
Please show me something that the traditional method can't do.
Function getIndexOf ( aData: tDataType ) = result: integer;
var data: tDataType;
begin (* getIndexOf *) result:= 0; data:= someFirstDataInForExampleALinkedList; while ( data <> aData ) and ( data <> nil ) do begin data:= getNextData ( data ); inc ( result ); (* ... and this is what you definitely need a result variable for. *) end (* while *); end (* getIndexOf *);
Of course, you also can do so by explicitly declaring `result`as a local variable and assigning it to getIndexOf in the end, but personally, I find the above way far more elegant.
Frank: Would it cause much effort/pain to make the old syntax possible again? ______________________________________________________________ Verschicken Sie romantische, coole und witzige Bilder per SMS! Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193
Markus Gerwinski wrote:
CBFalconer wrote:
... snip usage of result vs assignment to function name ...
Please show me something that the traditional method can't do.
Function getIndexOf ( aData: tDataType ) = result: integer;
var data: tDataType;
begin (* getIndexOf *) result:= 0; data:= someFirstDataInForExampleALinkedList; while ( data <> aData ) and ( data <> nil ) do begin data:= getNextData ( data ); inc ( result ); (* ... and this is what you definitely need a result variable for. *) end (* while *); end (* getIndexOf *);
Of course, you also can do so by explicitly declaring `result`as a local variable and assigning it to getIndexOf in the end, but personally, I find the above way far more elegant.
Which, to me, means there are no new capabilities introduced by this usage. I find the local variable and final assignment to be much clearer and more elegant. All result has done is provide a synonym for the function name, whose use in an expression will not trigger recursion.