From jan@swi.psy.uva.nl Tue Feb 26 11:59:10 2002
Received: from there (jan@gollem.swi.psy.uva.nl [145.18.152.30])
	by swi.psy.uva.nl (8.11.6/8.11.2) with SMTP id g1QAxAu14118;
	Tue, 26 Feb 2002 11:59:10 +0100 (MET)
Message-Id: <200202261059.g1QAxAu14118@swi.psy.uva.nl>
Content-Type: text/plain;
  charset="iso-8859-1"
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: zze-PEX SOR balc031 FTRD/DTL/CAE  <pexsor.balc031@rd.francetelecom.com>
Subject: Re: [SWIPL] Problem with dynamic facts
Date: Tue, 26 Feb 2002 11:57:52 +0100
X-Mailer: KMail [version 1.3.2]
References: <91A311FF6A85D3118DDF0060080C3D82025ED503@lat3721.rd.francetelecom.fr>
In-Reply-To: <91A311FF6A85D3118DDF0060080C3D82025ED503@lat3721.rd.francetelecom.fr>
Cc: prolog
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

[Please keep things on the mailing list (and don't send attachments)]

On Tuesday 26 February 2002 11:44, zze-PEX SOR balc031 FTRD/DTL/CAE wrote:

> Here are information about my program!
>
> ------------------------------------------------------------------
> predicate_t assert_pred = PL_predicate("assert", 1, "user");
> term_t      h0 = PL_new_term_refs(1);
> String 	line =  "deduce([status], [none], [], [], signature).";
>
> PL_put_atom_chars(h0, (char*) line.c_str());
> PL_call_predicate(NULL, PL_Q_NORMAL, assert_pred, h0);

If you examine the database, you'll find a predicate

'deduce([status], [none], [], [], signature).'.

Note the quotes!  PL_put_atom_chars() creates an atom, not a term,
so you are calling

assert('deduce([status], [none], [], [], signature).').

You have to create a term and fill the arguments if you use the
C-interface.  The real C++ interface (see home page; there are
two now) allows for creating terms using the Prolog parser.  Note
however that this is a lot slower than creating the term using the
primitives and in most cases your term doesn't come from a fixed
string (otherwise you could have placed it in the Prolog code
right away).  If your term comes from something generated, building
the term becomes even more attractive as you don't have to deal
with quoting rules, allocate space for the string, etc.

	--- Jan

