[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: DEFSTRUCT and predicates
- To: common-lisp@SU-AI.ARPA
- Subject: Re: DEFSTRUCT and predicates
- From: NGALL@BBNG.ARPA
- Date: Tue, 26 Nov 1985 21:20:00 -0000
- In-reply-to: <WHOLEY.12162392973.BABYL@C.CS.CMU.EDU>
- Sender: NGALL@BBNG.ARPA
From: Skef Wholey <Wholey@C.CS.CMU.EDU>
To: Kent M Pitman <KMP@SCRC-STONY-BROOK.ARPA>
Subject: DEFSTRUCT and predicates
Date: Tuesday, 26 November 1985 14:49-EST
From: Kent M Pitman <KMP at SCRC-STONY-BROOK.ARPA>
The :PREDICATE option to DEFSTRUCT (CLtL, p312) violates the supposed
convention for the formation of predicate names (CLtL, p71) by blindly
adding -P to the end of the symbol rather than adding just "P" when
there is no "-" in the base symbol.
Yeah, at one point the language spec (or at least the language specifiers) said
that defstrict would "do the right thing" with defstruct predicates. This
decision was changed to the current one for some reason I don't recall. Note
that one can get the right effect by specifying the predicate name onesself.
As both an implementor and user of defstruct, I like the current situation -- I
don't think the naming conventions used by the system supplied functions should
be forced upon every single programmer.
Of course, Common Lisp follows a somewhat more complicated hueristic with
"-P"'ing things (e.g. Alpha-Charp). It's better that a program like defstruct
always do the same predictable dumb thing all the time than try to be clever
when it's going to be wrong occasionally.
The only complexity in the CL "-P" heuristic is dealing with qualified
predicates such as string-(lessp). Since defstruct created predicates
will ALWAYS be suffixing data-type names (NEVER existing predicate
names), defstruct can safely use the simple hyphenation heuristic,
i.e., if the data-type name is hyphenated, add "-P", otherwise add
"P". Can anyone think of counter-examples?
I think defstruct SHOULD obey the CL convention. At the very least,
it should be documented that it is BREAKING the convention.