unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Vincenzo Pupillo <v.pupillo@gmail.com>,
	55163@debbugs.gnu.org, Stefan Monnier <monnier@IRO.UMontreal.CA>
Subject: bug#55163: 29.0.50; master 4a1f69ebca (TICKS . HZ) for current-time broke lsp-mode
Date: Fri, 29 Apr 2022 18:44:54 -0700	[thread overview]
Message-ID: <156b848f-0ba3-a2d8-a343-314e24d37934@cs.ucla.edu> (raw)
In-Reply-To: <878rroi5a8.fsf@gnus.org>

On 4/29/22 02:54, Lars Ingebrigtsen wrote:

> Off the top of my head, we could have
> (file-attribute file 'modification-time) (i.e., have a &rest to specify
> the attributes, and don't return a list if there's one attribute, which
> is common).

Yes, one possibility is to generalize file-attributes's existing 
ID-FORMAT argument. For example, if (file-attributes "/") currently 
returns (t 20 0 0 (25196 16750 33564 745000) (25175 34183 905318 398000) 
(25175 34183 905318 398000) 4096 "dr-xr-xr-x" t 2 2053), then 
(file-attributes "/" '(mtime size dev)) would return just 
((1649902983905318398000 . 1000000000000) 4096 2053) - that is, just the 
requested components. And (file-attributes "/" 'size) would return just 
4096 as you suggest.

file-attributes's existing ID-FORMAT args 'integer' and 'string' would 
continue to have their current meaning for backward compatibility.


>  And we could have `time' instead of `current-time', with
> (time 'float) instead of `float-time' and even (time 'decoded) instead
> of `decode-time'.  Or `time-float', `time-decoded' with no parameters...

It sounds like the idea here is to use the prefix 'time' for 
time-related functions. Although I prefixed 'time-' to names of the time 
functions I added a few years ago (e.g., time-convert) I'm a bit leery 
about using the very-generic name 'time' for a new function. It's 
probably better to use a hyphenated name.


> introduce efficient functions with consistent
> naming, and then obsolete the old ones after a while.
For consistent naming, we could borrow names from GNU/Linux and POSIX, 
which have CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID. 
For example, we could have:

* (clock-realtime) returns the system-wide clock. It acts like 
(time-convert nil t), i.e., like (current-time) but returning (TICKS . 
HZ) form.

* (clock-process-cputime) returns the Emacs process's CPU-time clock; it 
would replace the recently-added current-cpu-time (except the obvious 
implementation would be less likely to wrap around).

* (clock-monotonic) is like (clock-realtime) except it cannot have 
negative clock jumps and its origin is unspecified. Emacs has nothing 
like this now; it would be useful for apps that keep event timestamps 
and want to know whether event A occurred before event B (current-time 
doesn't do that).

GNU/Linux has seven other kinds of clocks that could be useful, plus 
dynamic clocks, but we don't need to support them all, at least not 
until there's a demonstrated need.

Alternatively, if we'd rather not add one Lisp primitive per clock, we 
could add just one primitive (clock-time CLOCK) where CLOCK specifies 
the type of clock desired.





  parent reply	other threads:[~2022-04-30  1:44 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28 10:53 bug#55163: 29.0.50; master 4a1f69ebca (TICKS . HZ) for current-time broke lsp-mode Vincenzo Pupillo
2022-04-28 12:10 ` Lars Ingebrigtsen
2022-04-28 13:38   ` Eli Zaretskii
2022-04-28 20:15   ` Paul Eggert
2022-04-28 20:42     ` Vincenzo Pupillo
2022-04-28 21:55       ` Lars Ingebrigtsen
2022-04-28 21:51     ` Lars Ingebrigtsen
2022-04-29  9:54       ` Lars Ingebrigtsen
2022-04-29 10:54         ` Eli Zaretskii
2022-04-29 10:59           ` Lars Ingebrigtsen
2022-04-29 11:10             ` Eli Zaretskii
2022-04-29 19:38               ` Paul Eggert
2022-04-29 19:53                 ` Eli Zaretskii
2022-04-29 22:45                   ` Paul Eggert
2022-04-30  5:29                     ` Eli Zaretskii
2022-04-30  9:10                   ` Lars Ingebrigtsen
2022-04-30 10:00                     ` Eli Zaretskii
2022-04-30 20:51                       ` Paul Eggert
2022-05-01  5:38                         ` Eli Zaretskii
2022-05-01 15:00                           ` Paul Eggert
2022-05-01 15:42                             ` Eli Zaretskii
2022-05-01 16:17                               ` Paul Eggert
2022-05-01 16:43                                 ` Eli Zaretskii
2022-05-02 17:27                                   ` Paul Eggert
2022-05-02 17:58                                     ` Eli Zaretskii
2022-05-02 23:17                                       ` Paul Eggert
2022-05-03  2:32                                         ` Eli Zaretskii
2022-05-03  2:52                                           ` Paul Eggert
2022-04-30  1:44         ` Paul Eggert [this message]
2022-04-30  5:40           ` Eli Zaretskii
2022-04-30 11:21             ` Vincenzo Pupillo
2022-04-30 11:25               ` Eli Zaretskii
2022-04-30 12:32                 ` Vincenzo Pupillo
2022-04-30 12:50                   ` Eli Zaretskii
2022-04-30 13:22                     ` Vincenzo Pupillo
2022-04-30  9:15           ` Lars Ingebrigtsen
2022-04-30 21:03             ` Paul Eggert
2022-05-01  5:40               ` Eli Zaretskii
2022-05-01 15:08                 ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=156b848f-0ba3-a2d8-a343-314e24d37934@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=55163@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=monnier@IRO.UMontreal.CA \
    --cc=v.pupillo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).