GNU bug report logs -
#69739
30.0.50; `type-of` is not precise enough
Previous Next
Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>
Date: Mon, 11 Mar 2024 23:22:01 UTC
Severity: normal
Found in version 30.0.50
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
Message #23 received at 69739 <at> debbugs.gnu.org (full text, mbox):
>> >> Still, any change as suggested here would be an incompatible change, so
>> >> there's risk it'll break some code out there (`type-of` is not used very
>> >> often, but it *is* used). Another option is to introduce a new function
>> >> which does the same as `type-of` but with changes like the ones above.
>> >> (we could even decide to give it a `cl-generic-` prefix to discourage
>> >> its use elsewhere so we can be more free to change its return value in
>> >> the future).
>> > I'd prefer a non-breaking change, if possible and reasonable.
>>
>> Suggestion for a good name for that new function?
>
> cl-generic-type-of is one.
>
>> Should it make `type-of` obsolete?
>
> I don't have an opinion on this. Depends on how much type-of is used,
> I guess. Maybe we should wait for the next major release and decide
> whether to deprecate then?
In my review of uses of `type-of`, I found:
- The most common seemed to be when generating error messages like
(error "Arg should be an int rather than a %s" (type-of arg))
- The next most common was misuses like (eq (type-of FOO) 'BAR)
which should be using `BAR-p` instead (or `cl-typep`).
- The next most common was when `type-of` is applied to a struct
(i.e. it returns the same as (aref FOO 0)). Since this was new
functionality in Emacs-26, I'm surprised at how widespread it is.
- There were a few that are combined with case/pcase and would probably
be better served by `cl-typecase`.
I think that marking it obsolete wouldn't be an option if the new
function is named something like `cl-generic-type-of`: it would have to
be a more "neutral" name.
The reason why I'd like to make it obsolete (if it can't be changed) is
to try and avoid having two slightly-different functions where most
users don't actually care about the difference.
Stefan
This bug report was last modified 1 year and 121 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.