[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] trunk r113747: lisp/frameset.el: Convert `frameset' to

From: Stefan Monnier
Subject: Re: [Emacs-diffs] trunk r113747: lisp/frameset.el: Convert `frameset' to vector and add new slots.
Date: Thu, 08 Aug 2013 00:09:49 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> Not in CL parlance: a predicate is "a function that returns a
> generalized boolean as its first value." No other restrictions.  It's
> the callers' responsibility to treat its result as a boolean.

So we agree: the return value should be treated as a boolean, even if it
may not always be restricted to t or nil.  So it shouldn't document its
return value as being something else.

> Both are hidden, as it is something that you don't ever see (except,
> in this case, in the frameset-p predicate). But, if you ever happen to
> see the tag, cl-struct-frameset is horrible. "cl-defstruct-" is jus
> the implementation leaking.

Actually, if we ever want to save those vectors to a file, then I agree
that `frameset' is indeed better than `cl-defstruct-frameset'.  I had
forgotten about this point.

> But the deeper question is, I really prefer to have a more checking
> frameset-p. I want to discourage people of going the make-frameset
> route and using frameset-save instead.

Then why don't you remove make-frameset and replace it with a good
constructor which can only build elements that agree with your tighter
constraints?  You wouldn't need to check those constraints in frameset-p
any more since they'd be true by construction.

>> That's it's more idiomatic?
> A predicate is something that checks inclusion in a type.

Indeed.  Not something that returns a version number.

> [cl-struct-frameset "Hello" "Goodbye" 'nothing 'to 'see 'here [0 0 0]]
> is not a frameset, even if the built-in frameset-p thinks so.

It's a frameset, it's just not a valid one.  If/when cl-defstruct is
extended to support type annotations on its slots, then I might agree with
you, but note that if this ever happens, the type checks will not be in
frameset-p but in the constructors and the setters.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]