Git Product home page Git Product logo

Comments (2)

scymtym avatar scymtym commented on August 18, 2024

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.

robert-strandh avatar robert-strandh commented on August 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.