Article View: comp.lang.prolog
Article #1275Re: Standards question: behavior of arg/3
From: Dan Brahme
Date: Thu, 18 Oct 1990 15:44
Date: Thu, 18 Oct 1990 15:44
56 lines
2442 bytes
2442 bytes
bs30@GTE.COM (Bernard Silver) writes:
>The latest draft of the ISO Prolog standard has recently come out.
>One thing that caught my attention is the specified error behaviour
>for the predicate arg/3. We (the ANSI group) are interested in
>finding out how people use this predicate.
First,
Can the ISO people post a readable draft of the standard that they
are proposing to this news group?
>The ISO draft specifies that arg(N,Term,Arg) (with N and Term
>instantiated) reports a range error if N is greater than the arity of
>Term. In contrast, many existing Prologs just quietly fail in
>this situation. Which do you prefer? In particular, do your programs
>ever rely on the quiet failure to end a recursion?
If the ISO standard arg(N, Term, Arg) reports error when N is greater
than the arity, it is a nuisance.
Then we cannot do
bagof(Arg, N^arg(N, Term, Arg), Args).
or
bagof(Arg, N^(positive_integer(N), arg(N, Term, Arg)), Args).
where positive_integer is
positive_integer(1).
positive_integer(N) :- positive_integer(N1), N is N1 + 1.
to get a list of args.
>If you believe in quiet failure, when should arg/3 raise an error?
>Is arg(-3,Term,Arg) ok? What about arg(a,Term,Arg)?
arg(-3, Term, Arg) is OK
while arg(a, Term, Arg) is NOT OK and should report as a error.
>We would appreciate any comments!
I agree with Richard that you should have a set of
principles to decided when a predicate should or should
not report a error.
The other alternative is post all the built-in predicates
and a list of questions like the one for arg and let
everybody vote depending on what they feel should
be the behavior of the built-in. With this mechanism
the standard behavior of each predicate is determined
by majority vote.
I think both approaches are fine by me. Though the second
approach fits in more with american style of democracy. :-)
Dan Brahme
Texas Instruments
Technical Details
Message-ID:
<brahme.656264677@vlsic2>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!cs.utexas.edu!csc.ti.com!ti-csl!m2.csc.ti.com!vlsic2!brahmeReferences:
<9888@bunny.GTE.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!cs.utexas.edu!csc.ti.com!ti-csl!m2.csc.ti.com!vlsic2!brahme From: brahme@vlsic2.ti.com (Dan Brahme) Newsgroups: comp.lang.prolog Subject: Re: Standards question: behavior of arg/3 Keywords: ANSI, standard Message-ID: <brahme.656264677@vlsic2> Date: 18 Oct 90 15:44:37 GMT References: <9888@bunny.GTE.COM> Sender: usenet@csc.ti.com (USENET News System) Organization: Texas Instruments Inc, VLSI Design Lab, Dallas, TX Lines: 56