[mercury-users] An ugliness in the language (char literals)
schachte at cs.mu.OZ.AU
schachte at cs.mu.OZ.AU
Wed Aug 2 15:42:24 AEST 2000
On 2 Aug, Fergus Henderson wrote:
> Well, you could argue that Prolog does have any types at all.
Just one type: term.
> But if you accept that Prolog does have types, just dynamically
> checked ones, what is the type of the ISO Prolog predicate `atom_chars'?
I'm not sure I do accept that, or at least there are a few different
things you could call the type of an argument (what can be passed
without causing an error, or what could lead to a success, for
starters).
But if you want a type for the second argument of atom_chars, how about
list of integer, or maybe list of character code. Or maybe list of
character code of length not greater than the length limit for atoms.
> Prolog allows the programmer to use either single-character atoms _or_
> integer codes. The use of integer codes is more common, but it's
> certainly not the only option.
Oh, that's right, they did wind up putting that into the standard. A
mistake, I think. A genuine character type would be OK, as long as
sensible arithmetic operations work on it. You'd get a little bit of
useful error checking out of it (you couldn't multiply two characters,
for example), but it wouldn't be an undue burden on sensible character
operations. But I don't think single-character atoms make much sense,
because it *is* an undue burden, and it *doesn't* give you checking.
Mercury does have a genuine character type, but gets into trouble
because it's not a distinct token class, so as far as the parser is
concerned, there is no character type. As far as I can see, to fix this,
you'd have to make a significant non-backward-compatible change.
--
Peter Schachte The use of COBOL cripples the mind; its
mailto:schachte at cs.mu.OZ.AU teaching should, therefore, be regarded
http://www.cs.mu.oz.au/~schachte/ as a criminal offense.
PGP: finger schachte at 128.250.37.3 -- E. W. Dijkstra
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list