CBFalconer wrote:
Markus Gerwinski wrote:
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.
Exactly.
My issue here isn't about capability, but about readability. I usually try chosing my function names in a manner that you can use them just like verbs in normal talking. Using them as a noun when passing themselves as their own result always gave me a strange feeling, even back when I started my first steps in BP. Besides, since it can always happen that you run into that recursion at some point, I used to always declare the function's return value as a local variable whenever the function was bigger than a one-liner, even in my old BP days.
This may be a matter of taste, but I was really happy when GPC gained the ability to declare them in the function implementation's header, and I'd be really, really sad to lose it 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:
Markus Gerwinski wrote:
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.
My issue here isn't about capability, but about readability.
And, on the contrary, my issue was about capability. The readability is a style issue. My only concern is whether I am missing some capability issue by eschewing the result mechanism.
Markus Gerwinski wrote:
CBFalconer wrote:
Markus Gerwinski wrote:
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.
Exactly.
My issue here isn't about capability, but about readability.
It's also a bit about efficiency. While the backend can probably optimize it for simple types, results of larger types (e.g., strings) will cause extra assignments when done this way.
I usually try chosing my function names in a manner that you can use them just like verbs in normal talking. Using them as a noun when passing themselves as their own result always gave me a strange feeling, even back when I started my first steps in BP. Besides, since it can always happen that you run into that recursion at some point, I used to always declare the function's return value as a local variable whenever the function was bigger than a one-liner, even in my old BP days.
This may be a matter of taste, but I was really happy when GPC gained the ability to declare them in the function implementation's header, and I'd be really, really sad to lose it again.
I agree. This patch should change it back, unless `--object-pascal' is given. (markus10*.pas)
Frank
Frank Heckenbach wrote:
Markus Gerwinski wrote:
started my first steps in BP. Besides, since it can always happen that you run into that recursion at some point, I used to always declare the function's return value as a local variable whenever the function was bigger than a one-liner, even in my old BP days.
This may be a matter of taste, but I was really happy when GPC gained the ability to declare them in the function implementation's header, and I'd be really, really sad to lose it again.
I agree. This patch should change it back, unless `--object-pascal' is given. (markus10*.pas)
Yay! :-) Thank you very much!
Markus