Re: call, ..= operator, records (newbie)



levilista@xxxxxxxxx wrote:
I define a 'toy predicate' plus:

plus(X,Y):- Y is X+1.

Then I try the following:

24 ?- F=plus,F(2,X).
ERROR: Syntax error: Operator expected
ERROR: F=plus,F(2,X
ERROR: ** here **
ERROR: ) .

Why do I get an error here?
I know it can be solved with the introduction of a new variable (see
below) , but I'm just curious why.

26 ?- F=plus,X=..[F,2,Z], call(X).
F = plus,
X = plus(2, 3),
Z = 3.

:- X=..[plus,2,Y], X.

works for me too (swi)... as for why higher order predicates have to be explicit, i am too unaware of the context of the creation/standardisation of the language. i guess that seperate atom/function/predicate spaces play a role in this, but perhaps some of the prolog implementors on the list could help us out?

greetings Martin
.



Relevant Pages

  • Re: need help..
    ... >>> It should be a syntax error. ... an assignment is an expression ... in the context of a new language. ... CLC FAQ ...
    (comp.lang.c)
  • Re: need help..
    ... >>> It should be a syntax error. ... Making an assignment invalid in a condition but valid ... But I'd much rather just learn the language and use it. ... You can use your macros if you like, but I guarantee they'll make it ...
    (comp.lang.c)
  • Re: Underscores in Python numbers
    ... for aesthetic reasons: ... but why add special syntax that makes that sort of error MORE ... I've seen at least one language that allowed such ... but 9_1 would be a syntax error. ...
    (comp.lang.python)
  • Re: new/delete
    ... c language said: ... I am using pointer in my program. ... In C, that's a syntax error. ... rjh at above domain ...
    (comp.lang.c)
  • Re: call, ..= operator, records (newbie)
    ... On May 21, 4:04 pm, Martin Riener ... ERROR: Syntax error: Operator expected ... i guess that seperate ...
    (comp.lang.prolog)