[mercury-users] Functor(Arg) Terms Construction (Not Partially Instantitated?)
Goncalo Jorge Coelho e Silva
l10454 at alunos.uevora.pt
Mon May 19 02:06:35 AEST 2003
Hi,
Ralph replied on his post a while ago, that
partially instantiated terms would not work
in Mercury.
I've seen one can construct a specific functor(arguments)
term like:
:- type address == int.
:- type value == int.
:- type my_things ---> set_value(address, value).
main -->
{
Address = 1, Value = 1,
X = set_value(Address, Value)
},
run_instr(X).
run_instr(set_value(Address, Value))-->
io__write_string("Address"),
{
string__int_to_string(Address, Addstring)
},
io__write_string(Addstring),
...
But, would I be able to construct a functor(arguments) term
using a one-fits-all predicate like this one? (which wouldn't
take a partially instantiated term as an argument, would it?
Because both X,Y and Z are grounded at that time...)
(using this example of non-compilable Mercury, just to show
what I'd like)
:- type address == int.
:- type value == int.
:- type my_things ---> set_value(address, value).
main -->
{
X = 1,
Y = 1,
Z = "set_value",
Term = Z(X, Y)
},
run_instr(Term).
run_instr(set_value(Address, Value))-->
...
I got this, but I couldn't quite know how to
recriate the types the compiler asks me
about:
inter.m:026: In clause for predicate `inter:main/2':
inter.m:026: in unification of variable `Term'
inter.m:026: and term `''(Z, X, Y)':
inter.m:026: type error in argument(s) of functor `/3'.
inter.m:026: Argument 1 (Z) has type `string',
inter.m:026: expected type was `(func(V_2, V_1) = V_3)';
inter.m:026: argument 2 (X) has type `int',
inter.m:026: expected type was `V_2';
inter.m:026: argument 3 (Y) has type `int',
inter.m:026: expected type was `V_1'.
So, would it be possible to create a one-fits-all
functor(arg) creation predicate in Mercury?
Thanks a lot,
Goncalo
--------------------------------------------------------------------------
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