lagache@violet.berkeley.edu (Edouard Lagache) (03/28/88)
Chris Moss in one of his postings on strings complained
about the need to have ASCII character codes appearing in his
PROLOG programs. His complaint is a sound one that should
be easily solved. My now feeble brain-box clicked and
whirred, and quickly spitted out: "In C, double quotes are
used for strings, and single quotes are reserved for
characters - simple right?". Unfortunately, 1/2 a chick
later it occurred to me that single quotes are sort of
already taken, so that solution was dashed.
Undaunted, my brain whirred again and this time fixed on
a fragment from my LISP programming days: "what about using a
backquote?". A quick check of the file cabinets didn't find
any use of the backquote in PROLOG, and that like LISP a
single quote operator would be needed since this quote would
simply convert the next character (whatever it is) to its ASCII
value.
Experiencing the joy of victory, my brain quickly
proceeded to push this small achievement over the edge (of
the cliff): "Sucks, I can write a tiny function and operator
to do this with my PROLOG and I will actually have a working
model!"
Two problems quickly arose: 1.) PROLOG operators
require a space, which detracts from the effect of a quote
(i.e. ` a instead of `a ), and 2.) You are still thinking
LISP, You can't write functions in PROLOG dummy! Oh well, so
the dream dies, but one can still mock up the basic concept
with a two place operator and predicate. The code is below.
That still doesn't solve the problem of is the backquote
really free for this job, and if one really wants an internal
operator of this sort. I kind of like the idea (as I am sure
you suspected!) What does the rest of the world think?
Weary as ever! Edouard Lagache
lagache@violet.berkeley.edu
/************************************************************************/
/* A mockup of the backquote to serve to expand ASCII characters */
/* into their collating sequence, The syntax isn't ideal. This scheme */
/* is of the form: X ` a, while the ideal form would probably be `a. */
/* */
?-op(100,xfx,'`').
Code ` Char :- name(Char,[Code]).