Comments (2)
Would writing the body as
(and (not (null (c2mop:slot-definition-initargs slot)))
(not (null (slot-type->cardinality (c2mop:slot-definition-type slot)))))
make the function easier to understand? The function is used as a predicate, is named like a predicate and would, when changed like that, also behave like a predicate.
from architecture.builder-protocol.
Not much.
It looks to me like there ought to be a name for the case where the
the type of the slot is NIL, like SLOT-HAS-CARDINALITY-P (I am just
guessing, I don't know the right name), so that slot-type->cardinality
would signal an error if this new thing returns NIL.
In other words, I think it is confusing to overload a function with a
name that suggests that it returns a cardinality so that it also
returns NIL when there is no cardinality available. You could of
course rename it to
slot-type->cardinality-or-nil-if-there-is-no-cardinality, but when
names must look like this to explain what they do, it indicates to me
that there is something wrong with the abstraction.
I know that there are plenty of standard functions that do this, and
this practice was no doubt kept for reasons of backwards
compatibility. We all learn how these functions work after many years
of practice, but I don't think it is a good idea to continue this
practice in new code that new people must read and understand.
I also know that a library such a Clostrum contains many cases of NIL
being returned as a default value, like for FDEFINITION. However, the
Clostrum functions mimic standard functions which is part of the
reason. And, I don't use a call to FDEFINITÎON in a context where a
Boolean value is expected.
Then, if the universal builder is not a good idea, it doesn't matter
much.
from architecture.builder-protocol.
Related Issues (11)
- Incorrect indentation of class-initarg-and-relation-slots HOT 2
- Hard to understand documentation string of cardinality-case. HOT 1
- Maybe do not use &REST as a lexical variable
- Improve documentation string for generic function FINISH
- In make-keyword-argument, handle base cases first
- Starting ASDF system definitions by (in-package #:asdf-user) HOT 2
- Iterative version of make-keyword-arguments HOT 2
- Improve comment for make-keyword-arguments
- Hard to parse phrase in the documentation string of add-relations.
- Incorrect indentation in add-relations
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from architecture.builder-protocol.