regarding arg/3

Discussion on the revision of the current Core standard

Moderator: Paulo Moura

regarding arg/3

Postby v » Fri Mar 21, 2008 12:12 pm

Code: Select all
arg(N, Term, Arg). % N'th argument of Term = Arg


Currently (ISO) arg/3 fails immediately if N is unbound, why not have it enumerate each N, 0 =< N < arity of Term?

then the following would happen:
Code: Select all
?- arg(N, foo(x,y,z), Arg).

N = 1,
Arg = x ;

N = 2,
Arg = y ;

N = 3,
Arg = z


(this already works in SWI by the way, but not GNU)
v
 
Posts: 3
Joined: Fri Mar 21, 2008 11:46 am

Re: regarding arg/3

Postby Paulo Moura » Fri Mar 21, 2008 3:43 pm

v wrote:Currently (ISO) arg/3 fails immediately if N is unbound, why not have it enumerate each N, 0 =< N < arity of Term?

The ISO Prolog specification of the arg/3 predicate mandates an instantiation_error exception when N is unbound.

Cheers,

Paulo
Paulo Moura
Logtalk developer
Paulo Moura
Site Admin
 
Posts: 18
Joined: Sun May 13, 2007 11:32 am
Location: Portugal


Return to Core Revision

Who is online

Users browsing this forum: No registered users and 1 guest

cron