3 ms·
A function returns a value. It doesn't really apply in C type dialects because everything is a function, but in Pascal type dialects, they were distinct as they
by Clubber 9y ago
A function returns a value. It doesn't really apply in C type dialects because everything is a function, but in Pascal type dialects, they were distinct as they are in PLSQL and TSQL. If you wrote anything in Delphi, you would have to know that, thus why we asked it. It's actually declared that way.
procedure ShowTime; // A procedure with no parameters
begin
// Display the current date and time
ShowMessage('Date and time is '+DateTimeToStr(Now));
end;
function Average(a, b, c : Extended) : Extended;
begin
// return the average of the 3 passed numbers
Result := Mean(a, b, c);
end;
Edit: thanks for the formatting tip.
http://www.delphibasics.co.uk/Article.asp?Name=Routines http://www.delphibasics.co.uk/Article.asp?Name=Routines
- gt2 9y agoseems like a silly gotcha -- a literal technicality. Aren't you worried you passed on some amazing talent because they didn't read the same "bibles" or study in the same "groups" as you?
- Clubber 9y agoYou literally couldn't program in Delphi if you didn't know that.
- Stratoscope 9y agoSure, if you were hiring someone with no Delphi/Pascal experience, for example a programmer who had worked in multiple languages and you expected to be able to learn Delphi quickly, then it would be a silly gotcha. But if you were interviewing someone who claimed to know Delphi/Pascal at all and didn't know this off the top of their head, it would be a big red flag. It would be like asking a C programmer what's the difference between "void foo(){...}" and "int foo(){...}". They had better be able to tell you the difference without having to think about it.
- Clubber 9y agoIt's funny. Based on the responses, I can tell who has Delphi experience and who does not. Pretty good interview question for Delphi devs, I'd say. :) Sure beats 5 hour interviews about God knows what.
- marcosdumay 9y agoIf you were programing in Pascal for 5 minutes, you would know the answer. It is a technicality, but a plainly accessible one. If "knows Pascal" is one of the job requirements, it's actually a good question.
- mikestew 9y agoI haven't touched Delphi in twenty years, and I still remember the difference. It's fizz-buzz for Delphi devs: if you say you're a Delphi dev and don't know this off the top of your head, then you're lying about your experience.
- Stratoscope 9y ago> Sorry, don't know how to format code on here. Two spaces at the beginning of each line. And you have two hours to edit a comment. :-)