[mercury-users] Style, Newbie decision question, "What? No X?!", Microbenchmark

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Nov 21 03:05:00 AEDT 2002


On 20-Nov-2002, Julian Fondren <cleverjulian at hotmail.com> wrote:
> Ralph Becket wrote:
> >Please use ( if _ then _ else _ ) rather than ( _ -> _ ; _ ).
> 
> Even the Mercury documentation seems consistent in its use of
> ( _ -> _ ; _ ); why do you prefer ( if _ then _ else _ )?

"if ... then ... else ..." is clearer to those not familiar with Mercury
syntax, and is also harder to confuse with disjunction.

> (Another
> style issue I forgot to question: should ':' or '__' be used for
> fully-qualified imports?  Erlang uses ':', so I've become fond of
> that, but __ is also fairly consistently used.)

Use "__".  Our plan is that ":" is going to change meaning in a future
version of Mercury -- ":" will mean `with_type`, and "." will be used for
module qualification.

> >chomp(S0) = ( if string__remove_suffix(S0, "\n", S) then S else S0 ).
> 
> (almost following your earlier style:)
> 
> chomp(S0) =
>   (      if string__remove_suffix(S0, "\r\n", S) then S
>     else if string__remove_suffix(S0, "\n",   S) then S
>     else                                              S0
>   ).
> 
> ... but it occurs to me that I don't really need the first case.

Yes, the Mercury library automatically handles conversion of \r\n to
\n for text-mode input files on Dos/Windows, just like the C library does,
so normally you don't need to handle that yourself.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list