« Return to Thread: strings and atoms with JPL
In JPL, there seems to be no distinction between a
string and a "classical" atom.
Victor NOEL wrote:Then you are thinking of "quoted atoms", which are atoms
Hello,
I am wondering how can strings be used with JPL, and more
generally, what is the link between atoms and strings.
What I think is :
strings are atoms with " ' " before and after.
whose names are quoted within a Prolog source text, perhaps
because they would otherwise be misinterpreted or illegal:
2+2 == +(2,2)
but
'2+2' denotes an atom whose name has three characters.Nor is there in Prolog (except in input, output and source
In JPL, there seems to be no distinction between a
string and a "classical" atom.
syntax).JPL's jpl.Term class and its subclasses provide an alternative
Are things like that ? Am I missing something ?
I am asking this because I am wondering if strings in JPL should
be treated differently than atoms or not, more specifically,
should I think that any string (used in the context of JPl of
course, in a term for example) *is* an atom ? Or is there a difference that make strings to be treated differently than atoms ?
concrete syntax for Prolog, in which atom names such as 2+2 do
not need to be quoted as above, hence
new jpl.Atom("2+2")
creates an atom identical to that denoted, in Prolog source, by
'2+2'. I trust the need for double quotes is understood ;-|
Of course, if you use JPL's convenience methods to create terms
from Prolog source fragments, then you'll still need to quote
such atoms, e.g.
jpl.Query.oneSolution("assert(is_an_atom('2+2'))")regards - Paul Singleton
Thanks you for your help :)
Victor
------------
For further info, please visit http://www.swi-prolog.org/
To unsubscribe, send a plaintext mail with "unsubscribe prolog <e-mail>"
in its body to majordomo@...
« Return to Thread: strings and atoms with JPL
| Free Forum Powered by Nabble | Forum Help |