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: Extentions to BASIC
    ... There's a blast from the past. ... This language, developed at the Hanover College for Technical ... Misfits, was designed to make it impossible to write code with errors in it. ... you can't make a syntax error. ...
    (sci.electronics.design)
  • Re: A C Adventure: your comments are welcome
    ... syntax error even in C99. ... If lcc-win32 supports this (which I doubt ... and the obvious compilation errors it causes can be fixed without ... (I think it can happen with *any* language that has comments that finish at ...
    (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)