Function Result Name (Obscure Syntax #5) - Delphi #154

preview_player
Показать описание

Alister Christie is a Delphi MVP (Most Valued Professional), Consultant, Developer, Trainer, Presenter, and Author. He has presented at ADUG (Australasian Delphi Users Group) Symposia and Code Rage Conferences for many years. Alister holds a degree in Mathematics and Computer Science from Victoria University, Wellington. He lives near Wellington, New Zealand.

On this YouTube Channel, Alister has created many hours of video tutorials to help you learn Delphi Programming in efficient and effective ways. Using his lessons, you will program faster and better, skills applicable for beginners through to experts wanting to expand their programming and coding proficiency.

Video topics by Alister Christie include VCL (Visual Component Library), FireMonkey, FireDAC, Cross-platform, Android, iOS (iPad or iPhone Operating System), Mac OS/X, Windows, IoT (Internet of Things), Algorithms, and more.

Рекомендации по теме
Комментарии
Автор

Yes, I knew about this. It took me a while adopt the "Result" way.

CapeCodGunny
Автор

Yes, both seen and used this syntax in old code. I wish there was a compiler flag to disable it, though. It really shouldn't be used.

AndreasToth
Автор

That was the only way to do it in Turbo Pascal. I still keep coming across it in my libraries and I upgrade it when I do. :-)

RohitGupta-jntt
Автор

That's the way I used to do it back in th TP 5.5 days, probably through to Delphi 3'ish

nicktucker
Автор

where is Exit('Some string');?

yegorstyblyna
Автор

I actually forgot this was a thing. I was aware of it but I've always used Result, not the function name. It's more clear that the Result of the function is to be set instead of the name of the function. (So maybe in my TP3 or TP5 days, I did that once or twice as a novelty, but I quickly dropped it just for the aesthetic)

MrPontiac
Автор

isn't that a recursive call if Foo is calling itself...?
i mean, sure it's a very simple function, but in a more complex function a recursive can be very tricky

eitan
Автор

Well there’s a case where this was actually useful. In a quite old very large function returning a Boolean value, there were a lot of sub-functions each returning a Boolean themselves. I’m not going to explain the whole logic of that function, but in a couple of sub-functions if an Exception was thrown the main function return value should be inverted, there the Result would map to sub-function return value, instead the “Foo” was the main return value. That’s the only case I found this useful. By the way I personally didn’t like how the code was written but it was so old and intricate into the 30 years old software (started in Pascal) I couldn’t rewrite that thing and had to accept it as is. So you always need to be sure you’re not going to change some logic by doing a Search&Replace.

ChristianCristofori
Автор

Not obscure at all :-), that's how I started programming, in the nineties

landaucorl