3
$\begingroup$

A lot of C-like programming languages (Java, C#, ...) use the following syntax for defining functions:

returnType functionName(parameters...) {
}

Is there a particular reason to do it that way ? (to put the return type first, on the left side). It is, I think, less natural than defining the function name first, then the inputs, then the output.

One reason I can see is that it match the way it will be called later on:

returnValue = functionName(...);

Some other languages (like Pascal, Rust, ...) put the return type on the right side:

function functionName(parameters...): returnType;
begin

end
$\endgroup$
3
  • 4
    $\begingroup$ Does this answer your question? What are the advantages/disadvantages of prefix type syntax? (also, welcome to PLDI!) $\endgroup$ Commented Aug 19, 2023 at 23:36
  • $\begingroup$ Is there a specific conception of "readability" you have in mind? Are you looking for empirical results? Is this a historical question about how this came about in existing systems? Please edit to narrow down the question to one particular version that can be given objective answers. $\endgroup$
    – Michael Homer
    Commented Aug 19, 2023 at 23:41
  • $\begingroup$ @RydwolfPrograms yes it does. I did a quick search before asking and did not find that answer. $\endgroup$
    – tigrou
    Commented Aug 19, 2023 at 23:43

0

Browse other questions tagged .