9

I am a Common Lisp newbie who's beginning to learn the language. My question is: I've seen several functions use the predicate syntax in different ways. For example (just looked this up), there is streamp and pathnamep, but there is also input-stream-p and output-stream-p. Why aren't all functions standardized to use *p or *-p? Is this maybe just a historical artifact?

3
  • 1
    Mostly historical -- Common Lisp largely ended up as a simple union of everything from every major Lisp implementation at the time, almost all thrown in together with more interest in ensuring that existing code would continue to work than in creating a language that really fit together well. Mar 26, 2013 at 15:30
  • 1
    This isn't actually 'syntax' - it is 'naming convention'
    – GoZoner
    Mar 26, 2013 at 20:45
  • 1
    @GoZoner Good point, fixed. Mar 26, 2013 at 21:12

1 Answer 1

12

The rule is that one-word predicate names end in just P, while multi-word predicate names end in -P. The reason for the former is mostly historical; the reason for the latter is that a name like input-streamp would wrongly suggest that the question being asked is “is this input a stream?” or something like that.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.