* bug#50214: 28.0.50; cl-struct changes may affect user packages in the wild
@ 2021-08-26 16:47 Adam Porter
2021-08-26 17:50 ` Arthur Miller
2021-08-26 19:37 ` Lars Ingebrigtsen
0 siblings, 2 replies; 8+ messages in thread
From: Adam Porter @ 2021-08-26 16:47 UTC (permalink / raw)
To: 50214
Hi,
A helpful user of my ts.el package discovered a change in Emacs 28
that breaks it:
https://github.com/alphapapa/ts.el/issues/18
Specifically, this commit changes the internal struct constructor from
a plist to an alist:
https://github.com/emacs-mirror/emacs/commit/3788d2237d4c65b67b95e33d1aca8d8b41780429
For example:
;; Emacs 28.0.50
(nth 1 (cl-struct-slot-info 'ts))
;; =>
;; (hour
;; nil
;; :type integer
;; (:accessor-init string-to-number
;; (format-time-string
;; "%H"
;; (ts-unix struct)))
;; (:aliases H)
;; (:constructor . "%H"))
;; Emacs 27.2.50
(nth 1 (cl-struct-slot-info 'ts))
;; =>
;; (hour
;; nil
;; :type integer
;; :accessor-init (string-to-number
;; (format-time-string
;; "%H"
;; (ts-unix struct)))
;; :aliases (H)
;; :constructor "%H")
Unfortunately this breaks how ts.el works. Of course, that can be
worked around with a version check, but that means that users who
upgrade to Emacs 28 without upgrading ts.el will encounter failures.
I don't know if this is something you'd want to reconsider. I guess
there was a good reason for the changes being made. And maybe what
ts.el is doing is considered unsupported, which would seem like a
not-unreasonable position.
Anyway, I'm reporting this so the issue is officially documented and
any decisions can be made accordingly.
Thanks,
Adam
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#50214: 28.0.50; cl-struct changes may affect user packages in the wild
2021-08-26 16:47 bug#50214: 28.0.50; cl-struct changes may affect user packages in the wild Adam Porter
@ 2021-08-26 17:50 ` Arthur Miller
2021-08-26 19:37 ` Lars Ingebrigtsen
1 sibling, 0 replies; 8+ messages in thread
From: Arthur Miller @ 2021-08-26 17:50 UTC (permalink / raw)
To: Adam Porter; +Cc: 50214
Adam Porter <adam@alphapapa.net> writes:
> Hi,
>
> A helpful user of my ts.el package discovered a change in Emacs 28
> that breaks it:
>
> https://github.com/alphapapa/ts.el/issues/18
>
> Specifically, this commit changes the internal struct constructor from
> a plist to an alist:
>
> https://github.com/emacs-mirror/emacs/commit/3788d2237d4c65b67b95e33d1aca8d8b41780429
>
> For example:
>
> ;; Emacs 28.0.50
> (nth 1 (cl-struct-slot-info 'ts))
> ;; =>
> ;; (hour
> ;; nil
> ;; :type integer
> ;; (:accessor-init string-to-number
> ;; (format-time-string
> ;; "%H"
> ;; (ts-unix struct)))
> ;; (:aliases H)
> ;; (:constructor . "%H"))
>
> ;; Emacs 27.2.50
> (nth 1 (cl-struct-slot-info 'ts))
> ;; =>
> ;; (hour
> ;; nil
> ;; :type integer
> ;; :accessor-init (string-to-number
> ;; (format-time-string
> ;; "%H"
> ;; (ts-unix struct)))
> ;; :aliases (H)
> ;; :constructor "%H")
>
> Unfortunately this breaks how ts.el works. Of course, that can be
> worked around with a version check, but that means that users who
> upgrade to Emacs 28 without upgrading ts.el will encounter failures.
>
> I don't know if this is something you'd want to reconsider. I guess
> there was a good reason for the changes being made. And maybe what
> ts.el is doing is considered unsupported, which would seem like a
> not-unreasonable position.
>
> Anyway, I'm reporting this so the issue is officially documented and
> any decisions can be made accordingly.
>
> Thanks,
> Adam
So what do we learn for the future? Don't use internal representation in your
apps, it is internal for a reason? :)
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#50214: 28.0.50; cl-struct changes may affect user packages in the wild
2021-08-26 16:47 bug#50214: 28.0.50; cl-struct changes may affect user packages in the wild Adam Porter
2021-08-26 17:50 ` Arthur Miller
@ 2021-08-26 19:37 ` Lars Ingebrigtsen
2021-08-26 20:52 ` Adam Porter
1 sibling, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-26 19:37 UTC (permalink / raw)
To: Adam Porter; +Cc: 50214
Adam Porter <adam@alphapapa.net> writes:
> A helpful user of my ts.el package discovered a change in Emacs 28
> that breaks it:
>
> https://github.com/alphapapa/ts.el/issues/18
>
> Specifically, this commit changes the internal struct constructor from
> a plist to an alist:
[...]
> I don't know if this is something you'd want to reconsider. I guess
> there was a good reason for the changes being made. And maybe what
> ts.el is doing is considered unsupported, which would seem like a
> not-unreasonable position.
I'm not very familiar with the internals of cl-struct, but if I
understand correctly, I think this is... well... an internal thing
that package writers should expect to change, so they shouldn't rely on
things like this.
But I've added Stefan to the CCs; perhaps he has some comments.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#50214: 28.0.50; cl-struct changes may affect user packages in the wild
2021-08-26 19:37 ` Lars Ingebrigtsen
@ 2021-08-26 20:52 ` Adam Porter
2021-09-04 17:37 ` Philipp
0 siblings, 1 reply; 8+ messages in thread
From: Adam Porter @ 2021-08-26 20:52 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 50214
On Thu, Aug 26, 2021 at 2:37 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:
>
> I'm not very familiar with the internals of cl-struct, but if I
> understand correctly, I think this is... well... an internal thing
> that package writers should expect to change, so they shouldn't rely on
> things like this.
Unfortunately, I know of no other way to implement what ts.el does
without modifying the accessors, which requires accessing the internal
struct details after it is defined. Unless I've missed something, or
something has changed, of course. Regardless, the library's been
working well for the almost 3 years since I wrote it, and it's used in
various packages now, even including a few not my own. :)
Anyway, if I have to add an Emacs-version check, that's not a big
deal. I'll just have to answer the inevitable "I upgraded to Emacs 28
and your package doesn't work anymore" reports.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#50214: 28.0.50; cl-struct changes may affect user packages in the wild
2021-08-26 20:52 ` Adam Porter
@ 2021-09-04 17:37 ` Philipp
2022-08-22 14:35 ` Lars Ingebrigtsen
0 siblings, 1 reply; 8+ messages in thread
From: Philipp @ 2021-09-04 17:37 UTC (permalink / raw)
To: Adam Porter; +Cc: Lars Ingebrigtsen, 50214
> Am 26.08.2021 um 22:52 schrieb Adam Porter <adam@alphapapa.net>:
>
> On Thu, Aug 26, 2021 at 2:37 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:
>>
>> I'm not very familiar with the internals of cl-struct, but if I
>> understand correctly, I think this is... well... an internal thing
>> that package writers should expect to change, so they shouldn't rely on
>> things like this.
>
> Unfortunately, I know of no other way to implement what ts.el does
> without modifying the accessors, which requires accessing the internal
> struct details after it is defined.
I haven't checked the code in detail, but AIUI ts.el tries to initialize structure members lazily? Why not just use a wrapper function for that?
(defun ts-hour (ts)
(or (ts--hour ts)
(setf (ts--hour ts) (string-to-number (format-time-string "%H" (ts-unix ts)))))
Here ts--hour is the actual accessor, which is private and shouldn't be used outside of ts.el.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#50214: 28.0.50; cl-struct changes may affect user packages in the wild
2021-09-04 17:37 ` Philipp
@ 2022-08-22 14:35 ` Lars Ingebrigtsen
2022-08-22 21:24 ` Adam Porter
0 siblings, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2022-08-22 14:35 UTC (permalink / raw)
To: Philipp; +Cc: Adam Porter, 50214
Philipp <p.stephani2@gmail.com> writes:
>> Unfortunately, I know of no other way to implement what ts.el does
>> without modifying the accessors, which requires accessing the internal
>> struct details after it is defined.
>
> I haven't checked the code in detail, but AIUI ts.el tries to initialize structure members lazily? Why not just use a wrapper function for that?
>
> (defun ts-hour (ts)
> (or (ts--hour ts)
> (setf (ts--hour ts) (string-to-number (format-time-string "%H" (ts-unix ts)))))
>
> Here ts--hour is the actual accessor, which is private and shouldn't be used outside of ts.el.
Adam, does this suggestion work for you?
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#50214: 28.0.50; cl-struct changes may affect user packages in the wild
2022-08-22 14:35 ` Lars Ingebrigtsen
@ 2022-08-22 21:24 ` Adam Porter
2022-08-23 10:08 ` Lars Ingebrigtsen
0 siblings, 1 reply; 8+ messages in thread
From: Adam Porter @ 2022-08-22 21:24 UTC (permalink / raw)
To: Lars Ingebrigtsen, Philipp; +Cc: 50214
Hi Lars,
Thanks for following up on this report.
On 8/22/22 09:35, Lars Ingebrigtsen wrote:
> Philipp <p.stephani2@gmail.com> writes:
>
>>> Unfortunately, I know of no other way to implement what ts.el does
>>> without modifying the accessors, which requires accessing the internal
>>> struct details after it is defined.
>>
>> I haven't checked the code in detail, but AIUI ts.el tries to initialize structure members lazily? Why not just use a wrapper function for that?
>>
>> (defun ts-hour (ts)
>> (or (ts--hour ts)
>> (setf (ts--hour ts) (string-to-number (format-time-string "%H" (ts-unix ts)))))
>>
>> Here ts--hour is the actual accessor, which is private and shouldn't be used outside of ts.el.
>
> Adam, does this suggestion work for you?
That seems like a good idea to me. I guess if I define it as an inline
function, it should have a similar optimization as the current code.
And the implementation would be much simpler and future-proof as well.
In hindsight, I should probably have tried that first. :)
I'll see if I can implement this in ts.el soon and release a new version
accordingly. In the meantime, I guess this bug report should be closed.
Thanks to all for your help.
Adam
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#50214: 28.0.50; cl-struct changes may affect user packages in the wild
2022-08-22 21:24 ` Adam Porter
@ 2022-08-23 10:08 ` Lars Ingebrigtsen
0 siblings, 0 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2022-08-23 10:08 UTC (permalink / raw)
To: Adam Porter; +Cc: Philipp, 50214
Adam Porter <adam@alphapapa.net> writes:
> I'll see if I can implement this in ts.el soon and release a new
> version accordingly. In the meantime, I guess this bug report should
> be closed. Thanks to all for your help.
No problem; closing this bug report, then.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-08-23 10:08 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-26 16:47 bug#50214: 28.0.50; cl-struct changes may affect user packages in the wild Adam Porter
2021-08-26 17:50 ` Arthur Miller
2021-08-26 19:37 ` Lars Ingebrigtsen
2021-08-26 20:52 ` Adam Porter
2021-09-04 17:37 ` Philipp
2022-08-22 14:35 ` Lars Ingebrigtsen
2022-08-22 21:24 ` Adam Porter
2022-08-23 10:08 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).