comp.lang.ada
 help / color / mirror / Atom feed
* Alternative syntax for function definitions?
@ 2012-10-27  6:30 Yannick Duchêne (Hibou57)
  2012-10-27  7:11 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 9+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2012-10-27  6:30 UTC (permalink / raw)


Hi people,

Just a silly idea I have sometime.

You know the question of having type at the left or at the right of a  
declaration, used to be discussed when comparing Eiffel or Pascal like  
syntax, to C like syntax. One argument is that “I : Integer;” is more  
natural than “int i;” because it do as a dictionary do, putting the  
defined element at the left. I have the feeling the question could  
similarly apply to the syntax used for function definition. I feel  
sometime, being able to write something as below, could be more readable:

     function P return T of (A1, A2, ...);

What's your feeling about such an alternative notation?

I feel it would be the most relevant when having a list of accessors  
functions, like in

    function P1 (A : A_Type) return T1;
    function P2 (A : A_Type) return T2;
    function P3 (A : A_Type) return T3;
    function P4 (A : A_Type) return T4;
    function P5 (A : A_Type) return T5;

Here, the most relevant part is the function names and their return type,  
and the argument is always the same, but it comes between both, and  
pollute the reading process, especially when the `(A : A_Type)` part is  
less short (which is common).

    function P1 return T1 of (A : A_Type);
    function P2 return T2 of (A : A_Type);
    function P3 return T3 of (A : A_Type);
    function P4 return T4 of (A : A_Type);
    function P5 return T5 of (A : A_Type);

The above is more readable I believe, and could be reasonable, as it adds  
no new reserved word does not create potential ambiguity with the existing  
syntax.

Similar comment would not apply to procedure (would not be useful, that's  
relevant with function definitions only).


-- 
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-10-29  2:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-27  6:30 Alternative syntax for function definitions? Yannick Duchêne (Hibou57)
2012-10-27  7:11 ` Dmitry A. Kazakov
2012-10-27  7:49   ` Yannick Duchêne (Hibou57)
2012-10-27  8:37     ` Dmitry A. Kazakov
2012-10-27  9:02       ` Yannick Duchêne (Hibou57)
2012-10-27  9:38         ` Bill Findlay
2012-10-27 11:13           ` Yannick Duchêne (Hibou57)
2012-10-27 23:46             ` Bill Findlay
2012-10-27  9:50         ` Dmitry A. Kazakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox