[mercury-users] Proposed change to char literal syntax
Julien Fischer
juliensf at csse.unimelb.edu.au
Thu Oct 5 11:37:47 AEST 2006
On Thu, 5 Oct 2006, Michael Day wrote:
> Hi Ralph,
>
>> I agree. In my experience, I usually start off thinking of using tricks
>> like this (although nothing as adventurous as this example), but
>> inevitably end up using longer, more meaningful names, such as
>> unicode_space. It makes things much less confusing and error prone in
>> the long run; the extra typing is more than compensated for by the
>> reduced debugging effort.
>
> Well, I see it as similar to the way in which the standard library has a
> bunch of different functions all called init: one returns a map, one returns
> a bimap, one returns a bag... and yet if you use the wrong one, the compiler
> will let you know.
>
> More specifically, I was trying to point out that if character literals were
> actually just function calls, then there would not need to be any special new
> syntax, as 'a' would still just be a quoted one letter symbol, that would
> resolve to :- func char.a = char assuming that you had imported the char
> module.
There's another issue here in that '' has a particular meaning in relation
to higher-order terms, see section 2.3 of the reference manual.
(Confusion between '' and functions like ' ' has resulted in broken code
in the past.)
Julien.
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to: mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions: mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the users
mailing list