-
Notifications
You must be signed in to change notification settings - Fork 20
true and false shouldn't be parsed as functors #49
Comments
That's moderately surprising to me; I thought |
They're certainly the two values that happen to be included in the set (In the same way, we could define
(1) By analogy with other built-in literals such as numbers, strings, and dynabases, which are also disjoint from atoms. Booleans are sufficiently special, common, and built-in that they should get this treatment too for consistency. (2) We have been careful not to pollute the functor namespace with our own keywords. That is why things like Hence, the user or the TSV importer can use arbitrary strings as functors without fear of collision, as long as they don't start with I don't see a reason to complicate that simple principle by making additional exceptions for |
On the other hand, I admit that it complicates Prolog's simple principle that identifiers starting with a lowercase character don't need to be quoted. So, you push it down there and it pops up here. (But not as badly, because at least we have the escape hatch of just quoting all functors. For a collision within a namespace, there's not much recourse.) |
Should lists not use |
Addresses #49; leaving open for subsequent discussion.
Sounds right. |
This is really only a problem for |
Well, a parser is entitled to eat up whatever characters it wants and interpret them however it wants. Special keywords don't necessarily have to map onto functors of the same name. But most of the things you're listing here, as well as infix I wanted to say that by contrast, Fundamentally I think my objection is that compound terms can serve as the names of items. I am afraid that if I guess there is an alternative design where Being able to treat expressions like Now, there's a question of exactly what terms are getting built by the functors you ask about: The simplest story is that So maybe I should just get the bee out of my bonnet and say "fine, in the same way, the atom term It's also possible that the builtins are not an incursion on the space of functors. We've discussed an import mechanism in which importing functors from another dynabase is really just sugar, as in many languages. It doesn't cause new items to be defined in the current dynabase. Rather, importing Assuming that this desugaring (like desugaring of infix operators) happens before quoting, then -- insofar as I can reconstruct our discussions of evaluation -- the functor of But anyway, under that design, When I said that perhaps the builtins are not an incursion on the space of functors, what I meant was that the user might still have some way to construct or receive terms with the ordinary And in fact, we could say that I wrote above:
In general I haven't liked that design in part because it means that the user's dynabase is full of junk. Dumping the current dynabase contents with I wrote above:
In a few of the cases you list, I'm not sure what compound term should be built, i.e., I'm not sure what the result of &-quoting the construct should be. First, is the (Note: The latter is at least an option, since I think user-defined syntax, at least, should probably allow the underlying form of the functor to differ from the surface syntax, e.g., the user can introduce I don't see a good reason to make the functor be |
The initial issue appears to be resolved. Can we close this ticket? |
Have nil and cons also become distinct from 'nil' and 'cons'? |
Whoop, I reverted this without thinking about it as part of the QPT branch, which did away with booleans-as-primitive-values. I'll put those back, I guess. |
true
andfalse
should be parsed specially as literals, just like123
would be.They are not 0-ary functors.
Of course, you can make any string into a functor (this is convenient when inventing functors from the header line of a TSV file, for example). So you can do so with these strings too, but you'd have to quote them.
At the moment, they seem to be functors. This means that the boolean
true
unifies with the 0-ary structure'true'
, which it shouldn't, just as the integer123
shouldn't unify with the 0-ary structure'123'
. It also means thattrace
sometimes prints&true
(which is as weird as printing&123
) -- see an example on #1.See also #48, but this is a different issue.
The text was updated successfully, but these errors were encountered: