Search
6:22:52
Lord_of_Life_
** NICK Lord_of_Life
9:42:26
lisp123_
Who prefers scheme's style of predicates (e.g. variable?) vs. CL's style (variablep)?
9:42:36
lisp123_
I think Scheme's style is better imo
9:43:59
pjb
anyways, ! and ? are normal characters in CL, and are reserved for user reader macros. So you can use them as you wish.
9:44:33
pjb
They're often used in pattern matchers (as prefix) ?foo indicates a variable to be bound.
9:44:49
lisp123_
pjb: i agree, now do you suggest me to use variable? in CL or should i stick to variablep?
9:45:03
lisp123_
because variablep is standard but a bit hard to identify the "p" at the end as its a normal letter
9:45:21
pjb
but not a common suffix.
9:46:25
lisp123_
how about variable-p?
9:47:14
pjb
there's a convention that single-word predicates use p as suffix, and multi-word predicates use -p
9:47:32
pjb
so we have variablep and blue-moon-p
9:47:36
lisp123_
there you go, let me follow that
9:47:55
pjb
BUT if the predicate name itself is prefixed, we don't modify it with a -p: string-lessp
9:48:05
pjb
the predicate name is lessp modified with string-.
9:48:18
lisp123_
I also reversed my original view of using "?" since its adding unnecessary attention to a simple function
9:48:19
pjb
It's not like we test for things that should be string-lesses.
9:48:29
pjb
If you wanted to test string-lesses, you'd use string-less-p
9:49:07
lisp123_
I thinks set! might be useful
9:49:08
pjb
It's just a matter of style, and sometimes style is inherited from foreign languages.
9:49:24
pjb
you could also have predicates such as: is-blue-moon
9:49:26
lisp123_
since assignment is such a tricky area, it adds some value
9:49:34
pjb
(if (is-blue-moon foo) (do-this))
9:49:45
lisp123_
pjb: actually what I have been doing sometimes is like this: (if blue-moon ...)
9:49:46
pjb
in a OO project, perhaps translated from other OO languages?
9:50:07
lisp123_
which is trying to make it as much "english" like as possible
9:50:12
pjb
It makes no difference to the compiler, it's only for the human reader.
9:51:25
lisp123_
i will stick to p and -p, although I don't 100% like them, its a pretty standard convention
9:51:37
wasamasa
emacs lisp prefers the p convention overall, but isn't 100% strict on it
9:52:07
lisp123_
wasamasa: good to know
9:52:25
pjb
(defstruct (point (:predicate pointp)) x y) (defstruct blue-moon mass) (and (pointp (make-point)) (blue-moon-p (make-blue-moon))) #| --> t |#