bug#47427: 26.3; 1. Please define a built-in predicate `plistp', 2. wrong type wrong-type-argument error

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#47427: 26.3; 1. Please define a built-in predicate `plistp', 2. wrong type wrong-type-argument error

Drew Adams
 (plist-put (list 'a 'b 'c) "a" 42)

Debugger entered--Lisp error: (wrong-type-argument plistp (a b c))
  plist-put((a b c) "abc" 42)
  eval((plist-put (list (quote a) (quote b) (quote c)) "abc" 42))

That's all fine and dandy, except that there is no predicate `plistp'.

See (elisp) Type Predicates:

  All built-in functions do check the types of their actual arguments
  when appropriate, and signal a 'wrong-type-argument' error if an
  argument is of the wrong type.

It makes no sense to refer to `plistp' in the error message if it
doesn't exist.  If it won't exist then the error message should say that
the arg isn't a plist - not mention `plistp'.  Even just saying "plist"
in the error message would be an improvement in this regard.  But the
right fix is to define a `plistp' primitive.

Not only that, but the error is _not_, apparently that the first
arg isn't a proper plist.  For example, this raises no error:

 (plist-put (list 'a 'b 'c) "a" 42)

And it returns the list (a 42 c).  Clearly the error was raised
not because of an improper plist but because the key to look up
is a string and the keys in the almost-plist are symbols.

In GNU Emacs 26.3 (build 1, x86_64-w64-mingw32)
 of 2019-08-29
Repository revision: 96dd0196c28bc36779584e47fffcca433c9309cd
Windowing system distributor `Microsoft Corp.', version 10.0.19041
Configured using:
 `configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static -g3''




Reply | Threaded
Open this post in threaded view
|

bug#47427: [External] : Re: bug#47427: 26.3; 1. Please define a built-in predicate `plistp', 2. wrong type wrong-type-argument error

Lars Ingebrigtsen
Drew Adams <[hidden email]> writes:

>> >  (plist-put (list 'a 'b 'c) "a" 42)
>> >
>> > Debugger entered--Lisp error: (wrong-type-argument plistp (a b c))
>> >   plist-put((a b c) "abc" 42)
>> >   eval((plist-put (list (quote a) (quote b) (quote c)) "abc" 42))
>> >
>> > That's all fine and dandy, except that there is no predicate `plistp'.
>>
>> The backtrace there doesn't seem to be a result of the example form,
>
> What do you mean by that?

The backtrace has "abc"; the code example does not.

> On the other hand, a probably more important question
> is the cost of getting the length of the list.  That
> would be my main hesitation to say we should really
> have a `plistp' predicate.

Why?  It's not like we'd use it for anything much.  

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#47427: [External] : Re: bug#47427: 26.3; 1. Please define a built-in predicate `plistp', 2. wrong type wrong-type-argument error

Drew Adams
> The backtrace has "abc"; the code example does not.

Yeah, sorry; typo.

> > On the other hand, a probably more important question
> > is the cost of getting the length of the list.  That
> > would be my main hesitation to say we should really
> > have a `plistp' predicate.
>
> Why?  It's not like we'd use it for anything much.

I meant that if we really had an (accurate) error msg
saying that the plist wasn't proper then in order to
test that for each `plist-put' or whatever we'd have
to traverse every plist argument, to see if it really
is proper.

To test that `(a b c)' isn't a proper plist we'd need
to check that the number of elements is even.

We could of course have a `plistp' predicate without
using it to test during `plist-put' etc.



Reply | Threaded
Open this post in threaded view
|

bug#47427: [External] : Re: bug#47427: 26.3; 1. Please define a built-in predicate `plistp', 2. wrong type wrong-type-argument error

Lars Ingebrigtsen
Drew Adams <[hidden email]> writes:

> I meant that if we really had an (accurate) error msg
> saying that the plist wasn't proper then in order to
> test that for each `plist-put' or whatever we'd have
> to traverse every plist argument, to see if it really
> is proper.
>
> To test that `(a b c)' isn't a proper plist we'd need
> to check that the number of elements is even.

We are not going to check that, because it wouldn't be
backwards-compatible.

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#47427: [External] : Re: bug#47427: 26.3; 1. Please define a built-in predicate `plistp', 2. wrong type wrong-type-argument error

Drew Adams
> > I meant that if we really had an (accurate) error msg
> > saying that the plist wasn't proper then in order to
> > test that for each `plist-put' or whatever we'd have
> > to traverse every plist argument, to see if it really
> > is proper.
> >
> > To test that `(a b c)' isn't a proper plist we'd need
> > to check that the number of elements is even.
>
> We are not going to check that, because it wouldn't be
> backwards-compatible.

Good.

If we don't use `plistp' in such cases then it's fine to
add it.  And it's not important to do so.

Then see my previous msg about the real problems.
This bug really shouldn't be about adding a `plistp'
predicate, as I indicated.  It all depends on how you
intend to deal with the real problems.