From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: encode-time vs decode-time Date: Mon, 19 Aug 2019 17:12:00 -0400 Message-ID: References: <502b23f8-58ed-38ff-ae50-fae391129a10@cs.ucla.edu> <87v9viuivo.fsf@mouse.gnus.org> <83blx2cr2o.fsf@gnu.org> <8336iecfvr.fsf@gnu.org> <68d24d6a-d427-baef-27e9-ea1cbbd64c18@cs.ucla.edu> <87sgqd9plt.fsf@mouse.gnus.org> <89271843-6d47-8315-ed9a-540657298985@cs.ucla.edu> <87v9uvmsfa.fsf@mouse.gnus.org> <83af2f70-480b-6e5f-06a5-876224e2b715@cs.ucla.edu> <88b57699-fbdb-bd43-6627-f7491b834955@cs.ucla.edu> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="155939"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Lars Ingebrigtsen , andrewjmoreton@gmail.com, Eli Zaretskii , emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 19 23:12:22 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hzowv-000eRk-I7 for ged-emacs-devel@m.gmane.org; Mon, 19 Aug 2019 23:12:21 +0200 Original-Received: from localhost ([::1]:57906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzowt-0000yS-W5 for ged-emacs-devel@m.gmane.org; Mon, 19 Aug 2019 17:12:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54833) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzown-0000y5-8i for emacs-devel@gnu.org; Mon, 19 Aug 2019 17:12:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzowl-0003vp-2y for emacs-devel@gnu.org; Mon, 19 Aug 2019 17:12:12 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:64326) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hzowj-0003vA-JP; Mon, 19 Aug 2019 17:12:09 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id BDABE81268; Mon, 19 Aug 2019 17:12:08 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 6B5B880A17; Mon, 19 Aug 2019 17:12:07 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1566249127; bh=RL4jkMkCaB5HEhfH20udDd57aeV23R5yHzoWOLrdRCI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=bT/HQFrdxoRjvNyYLwzxmjaASFwQ00a0wTyNmjdUh+5jXarc6Oe2/q9pu7LaGgdAS rRFHj5qTAfAJMq6mSaE3NvbuP6ANJyDhxHzYb0Xyv8q4882TPMbg9JhlGI97eM16Nh mFJUdlABRIq129vQ2DDL38BviSha2tWK9bGxNpdVIDpmzAYkB3PYo8wzSGDxnwVb/O 9+OgJyyfwt4hUGfVb9gCCQrIJo4Qd1/KFNvhkWPhHKriR0aU9xyYMAGuoBlp1RM6P5 8dCOWkU6QcezwCd7Rl7bhF4SBDRH93sICn412cXh6r6YJiTV9Qdgz0rOCEVXuJeQ9v GNGxHmzspqnHw== Original-Received: from alfajor (unknown [46.189.28.52]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 5E42D1203B6; Mon, 19 Aug 2019 17:12:05 -0400 (EDT) In-Reply-To: <88b57699-fbdb-bd43-6627-f7491b834955@cs.ucla.edu> (Paul Eggert's message of "Sat, 17 Aug 2019 15:53:13 -0700") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 132.204.25.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:239469 Archived-At: >> So maybe we should stop documenting "decoded time" objects as being of >> the form (SEC MINUTE HOUR DAY MONTH YEAR DOW DST UTCOFF SUBSEC), but >> instead say that it's a `decoded-time` object on which you can use >> the `decoded-time-*` accessors (and provide a corresponding pcase pattern >> to replace the `(,sec ,minute ...) one). > > That sounds like a reasonable way to move forward. > > I'm not a pcase expert. How would one go about doing the pcase stuff? That > is, how does one provide a pattern so that code like (pcase time > ((decoded-time :year y :month m) (some-expr-involving y & m))) can extract > the year and month components Y and M from the broken-down time TIME that > was created via (make-decoded-time :year y :month m)? Is there an example of > doing this sort of thing somewhere? With the cl-defstruct we use for decoded-time, we can already do: (pcase-let (((cl-struct decoded-time (second s) (minute m) hour day) time)) ...) so we could define (pcase-defmacro decoded-time (&rest fields) `(cl-struct decoded-time ,@fields)) OTOH it doesn't work in plain `pcase` currently because of a bug in the `cl-struct` pcase pattern (it expands to code which does (cl-typep XX 'decoded-time) but the way `decoded-time` is defined makes it unusable with `cl-typep`). Stefan