[m-rev.] diff: Update coding standard regarding if-then-else syntax

Peter Wang novalazy at gmail.com
Mon Nov 23 10:44:08 AEDT 2015


On Mon, 23 Nov 2015 10:34:11 +1100, Paul Bone <paul at bone.id.au> wrote:
> Update coding standard regarding if-then-else syntax
> 
> compiler/notes/coding_standards.html:
>     As above.
> ---
>  compiler/notes/coding_standards.html | 50 ++++++++++++++++++++++++++++++++----
>  1 file changed, 45 insertions(+), 5 deletions(-)
> 
> diff --git a/compiler/notes/coding_standards.html b/compiler/notes/coding_standards.html
> index b6cbd0a..30bd68a 100644
> --- a/compiler/notes/coding_standards.html
> +++ b/compiler/notes/coding_standards.html
> @@ -237,11 +237,54 @@ rather than having a separate mode declaration.
>  If-then-elses should always be parenthesized,
>  except that an if-then-else that occurs as the else
>  part of another if-then-else doesn't need to be parenthesized.
> -The condition of an if-then-else can either be on the same
> -line as the opening parenthesis and the `->',
> +Note that the
> +<code>( if <i>C</i> then <i>T</i> else <i>E</i> )</code> syntax is preferred
> +over the
> +<code>( <i>C</i> -> <i>T</i> ; <i>E</i> )</code> syntax.

Delete "Note that".

> +
> +<p>
> +The condition can either be on the same line as the '<code>if</code>'
> +keyword:
> +
> +<pre>
> +    ( if test1 then
> +        goal1
> +    ; else if test2 then
> +        goal2
> +    ; else
> +        goal
> +    )
> +</pre>

Delete semicolons.

> +
> +or if the test is complicated on separate line(s) between the
> +'<code>if</code>' and "<code>then</code>' keywords,
>  
>  <pre>
> +    ( if
> +        very_long_test_that_does_not_fit_on_one_line(VeryLongArgument1,
> +            VeryLongArgument2)
> +    then
> +        goal1
> +    else if
> +        test2a,
> +        test2b,

Delete trailing comma.

> +    then
> +        goal2
> +    else if
> +        test3    % would fit one one line, but separate for consistency
> +    then
> +        goal3
> +    else
> +        goal
> +    ).
> +</pre>
> +
> +When using the
> +<code>( <i>C</i> -> <i>T</i> ; <i>E</i> )</code> syntax The condition can

the (lowercase)

Peter



More information about the reviews mailing list