<p>A lot of C-like programming languages (Java, C#, ...) use the following syntax for defining functions:</p>
<pre><code>returnType functionName(parameters...) {
}
</code></pre>
<p>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.</p>
<p>One reason I can see is that it match the way it will be called later on:</p>
<pre><code>returnValue = functionName(...);
</code></pre>
<p>Some other languages (like Pascal, Rust, ...) put the return type on the right side:</p>
<pre><code>function functionName(parameters...): returnType;
begin

end
</code></pre>

<syntax><language-design><functions>
Is it more readable to declare the return type of a function on the left side of it's name?
CC BY-SA 4.0
2023-08-19T23:36:19.280Z
Does this answer your question? [What are the advantages/disadvantages of prefix type syntax?](https://langdev.stackexchange.com/questions/205/what-are-the-advantages-disadvantages-of-prefix-type-syntax) (also, welcome to PLDI!)
rydwolf
CC BY-SA 4.0
2023-08-19T23:41:53.553Z
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.
Michael Homer
CC BY-SA 4.0
2023-08-19T23:43:12.177Z
@RydwolfPrograms yes it does. I did a quick search before asking and did not find that answer.
tigrou
# Is it more readable to declare the return type of a function on the left side of it's name?
Posted by: username_0 on 2023-08-19
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
**Tags:** syntax language-design functions
> **Comments:**
> **username_1**: Does this answer your question? [What are the advantages/disadvantages of prefix type syntax?](https://langdev.stackexchange.com/questions/205/what-are-the-advantages-disadvantages-of-prefix-type-syntax) (also, welcome to PLDI!)  
> **username_2**: 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.  
> **username_0**: @RydwolfPrograms yes it does. I did a quick search before asking and did not find that answer.  
---
## 0 answers
