[mercury-users] very minor variable printing bug

Mark Brown mark at csse.unimelb.edu.au
Fri Oct 26 14:20:58 AEST 2007


On 26-Oct-2007, Nicholas Nethercote <njn at csse.unimelb.edu.au> wrote:
> Hi,
>
> It's not a big deal, but I thought I'd mention it:  if you have a variable 
> whose name begins with "V_" in a Mercury program, it seems that any error 
> message that mentions it prepends it with an additional "V_".
> Eg. in this type-incorrect line from a program I wrote:
>
>         VArray = [0-V_2, 1-V_1, 2-V_0],
>
> I get an error message:
>
> p.m:035: In clause for predicate `problem'/1:
> p.m:035:   in list element #0:
> p.m:035:   in unification of argument
> p.m:035:   and term `(V_42 - V_V_2)':
> p.m:035:   type error in argument(s) of functor `-/2'.
> p.m:035:   Argument 2 (V_V_2) has type `(fd.fdvar)',
> p.m:035:   expected type was `((fd.expression).var_expression)'.
>
> If I change V_2 to, say, Z_2, it's printed correctly as "Z_2".
>
> Maybe it's intended behaviour, but it took me a minute to work out what was 
> happening when I first saw it.

I guess it is intended to make it possible to distinguish between program
variables, and variables that the compiler introduced (such as V_42).

It would probably be better to print introduced variables as `__42' etc,
and prepend an extra underscore whenever a program variable might be
confused with an introduced variable.

Cheers,
Mark.
--------------------------------------------------------------------------
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