From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: arthur miller Newsgroups: gmane.emacs.devel Subject: RE: Docs for &optional and &rest arguments together Date: Thu, 31 Dec 2020 17:08:10 +0000 Message-ID: References: <87o8icq958.fsf@gnus.org> <877doyoa9g.fsf@gnus.org> , <20201231112634.GA5158@tuxteam.de> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_AM0PR06MB6577E3D461AC55FBA72BB37496D60AM0PR06MB6577eurp_" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29395"; mail-complaints-to="usenet@ciao.gmane.io" To: "tomas@tuxteam.de" , "emacs-devel@gnu.org" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 31 18:09:09 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kv1Rk-0007Xj-Mi for ged-emacs-devel@m.gmane-mx.org; Thu, 31 Dec 2020 18:09:08 +0100 Original-Received: from localhost ([::1]:57114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kv1Rj-0006nX-P0 for ged-emacs-devel@m.gmane-mx.org; Thu, 31 Dec 2020 12:09:07 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kv1Qy-0006EW-SQ for emacs-devel@gnu.org; Thu, 31 Dec 2020 12:08:20 -0500 Original-Received: from mail-am7eur06olkn2076.outbound.protection.outlook.com ([40.92.16.76]:60128 helo=EUR06-AM7-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kv1Qs-0003tP-Ay for emacs-devel@gnu.org; Thu, 31 Dec 2020 12:08:20 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HYscff84sF5ngPzusgqRBw2UTOVCobSHKebOFIkdl48OP7uf9HsC/beyEap92/UTjaXTab/Fugc0sSNRLkyCNVdo3zCsqJWjetPImmIM8iXEShhe01KADtgYGWqehIni6k6q4x/IJ66mGINU29CAis5uSjZTQU3s3cATBML1PE6op4ga3m8Dhdo18zo9im+bg8yHgANiPjbCPr8lWc8vD4uyY96D+H4JzP4zvOVOs39gkhwOL0v69fCbC4MC3b2nnLsK14Xr3r38ztmJCoh+P2rmEY1RIPa3KHj7ND7be4q36kb9+OgrQeuZvnN0fHy8yvMmUI5Y6sPapX/Rzccxew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7yKtpAJFbzsM9NvHcbmvod+NZGm6MVQ2IBXEQtLfcVU=; b=ZIFrp2mQ7sfkupCEXzNZqwoTtgzU4oF2i0K+CVS2efFZJwf3pldnD3gVFDZpDJNyk17/b6X/7/+wbxTzMWGQAovZ6oykNxEkeVipMq5IJFawaLmVTQoCzkeyzZM9zPtooJ5/FkLlSXRpRT8fgUqPwdh0po6ykNse5xdcAsbelYQUB8qgotVIeOUYSUwS8iqbLSFP3CVYbFjBVzLC+dRw8GhBuKGYX9lBbHF/2l9rOqFHB0MqxJy714vHefc9L4zLFfnFOeum+pa4NL1leM27FpjzC580wc4RcFABMVF0oS8vOkV5apl4VFRLnWmEmpSzs1qRr9i6eNNwXWZEVF+AKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7yKtpAJFbzsM9NvHcbmvod+NZGm6MVQ2IBXEQtLfcVU=; b=t1DnoJjxNQEwS1QBi5i4s0P5UlZhVVpJg4z5CUfulOPTqRGN1MKy0BHG3BAZcp5SLXeG3O35lXhMurXY6MhRO/ABl0IkWN9kqF8Yi2LfaNvgTXyKazvvYOWq4GAqpiHVy2IKlF9rdmPS+XXw1snKa7fIoE85hsXzVITYmtmbtxwuc6S6hMwebeHmDds8w5sydUQKeMJgjXqodKP/aMJ17oroicdWD4fzdGDvMx8NwWLd+VaqtCdNLPDvIhYMucrSa+j0SNGnX0uHIaN72U07N6aY5tU3SOaM9vW1ILEKbHu8FX6gabWAYoBaAUib/bvK5EUE2IymrBbirLfP1dwKHg== Original-Received: from AM7EUR06FT026.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4d) by AM7EUR06HT190.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.20; Thu, 31 Dec 2020 17:08:10 +0000 Original-Received: from AM0PR06MB6577.eurprd06.prod.outlook.com (2a01:111:e400:fc36::43) by AM7EUR06FT026.mail.protection.outlook.com (2a01:111:e400:fc36::393) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.20 via Frontend Transport; Thu, 31 Dec 2020 17:08:10 +0000 Original-Received: from AM0PR06MB6577.eurprd06.prod.outlook.com ([fe80::9487:8c7d:da00:4993]) by AM0PR06MB6577.eurprd06.prod.outlook.com ([fe80::9487:8c7d:da00:4993%7]) with mapi id 15.20.3700.031; Thu, 31 Dec 2020 17:08:10 +0000 Thread-Topic: Docs for &optional and &rest arguments together Thread-Index: AQHW3eY5w8c4C21GEEWOLQaTEmz/fKoQo1NHgAA1euaAADr9AIAAX3AI In-Reply-To: <20201231112634.GA5158@tuxteam.de> Accept-Language: sv-SE, en-US Content-Language: sv-SE x-incomingtopheadermarker: OriginalChecksum:33A8A82DA4035F4374FB4F92DFB3F03D63A6130BA0793DE54C10021F127B3D1D; UpperCasedChecksum:4FCDB11A853A20B576587EBCF0B224A47402091834DA8A8E10B477F6CEDD8343; SizeAsReceived:7158; Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [QalESKNp81d1x4AlPX2AqQH+VFkjAkub] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: f576a302-fab7-4bb3-d77f-08d8adaea687 x-ms-traffictypediagnostic: AM7EUR06HT190: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: DS0EKibGImW1ccLCCk/GePUl4ybneoCtG9i/W9KqOxKQLMwjjVhUvHPbIeXOuw8o2/5l5kOiKrn/QkJvNbuXLwTnZ1bpgIiU1ZwVPO/dWsdDr1k+A80qORi4iScHNkvtCWOgYhppnUH3poOeICFGSiOpMwRBVgYZM+/7lzQ5L/35lApDx6Aa7gOxNKKZKtaIr1iLIA7eBDF/P5lixbUgn8IZ47wnRi2b526trMH1ZB6QmIw6qYeu8asxwxSboI1V x-ms-exchange-antispam-messagedata: EwlO9QI2fnXlkQtBIyobAR2CQ94GMEx9ej7EUxWW0kpZUW8mpZpA6lAiCboz8e7yxyLRFWGE1RHkk1qgIm0PvsuHeAml5eFjKvU2nh311FFwpAeP3P+i2W3TNytwmjAJJS/VeuJMpOXQ7yipabx6kQ== x-ms-exchange-transport-forked: True X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT026.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: f576a302-fab7-4bb3-d77f-08d8adaea687 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Dec 2020 17:08:10.1784 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7EUR06HT190 Received-SPF: pass client-ip=40.92.16.76; envelope-from=arthur.miller@live.com; helo=EUR06-AM7-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:262183 Archived-At: --_000_AM0PR06MB6577E3D461AC55FBA72BB37496D60AM0PR06MB6577eurp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable It Is flera f=F6r me hos it work. What I am saying is that docs does not sa= y that we can't omit "optional" c or d when &rest is used. In the examples = you are illustrating with, one can't omit say d and write (foo a b c e), = both c and d are required, so user has to pass explicitly at least nil if n= ot d is provided: (foo a b c nil e) Documentation is talking about being able to omit either optional or rest a= rga, but does not touch on the case when one pass both optional and rest to= gether. In that case optional is not optional any longer. I don't understand why is it so difficult to see what I am talking about :-= ). Anyway: Happy new year's eve and all best in 2021! -------- Originalmeddelande -------- Fr=E5n: tomas@tuxteam.de Datum: 2020-12-31 12:27 (GMT+01:00) Till: emacs-devel@gnu.org =C4mne: Re: Docs for &optional and &rest arguments together On Thu, Dec 31, 2020 at 07:55:26AM +0000, arthur miller wrote: > I don't read it says both c and d are required when &rest is also used. You just have to squint the other way .-) They are not "required". They are provided -- in the call. It's just that c is served first, d next, and all the rest (if any) goes to e: (defun foo (a b &optional c d &rest e)) ...) If called like (foo 42) =3D> error (missing arg (foo 42 55) =3D> a -> 42 b -> 55 c -> nil d -> nil e -> nil (foo 42 55 67) =3D> a -> 42 b -> 55 c -> 67 d -> nil e -> nil (foo 42 55 67 92) =3D> a -> 42 b -> 55 c -> 67 d -> 92 e -> nil (foo 42 55 67 92 117) =3D> a -> 42 b -> 55 c -> 67 d -> 92 e -> (117) (foo 42 55 67 92 117 122) =3D> a -> 42 b -> 55 c -> 67 d -> 92 e -> (117) (foo 42 55 67 92 117 122 131) =3D> a -> 42 b -> 55 c -> 67 d -> 92 e -> (117 131) ... Thing is, when calling the function you have /no way/ to express which arg you are targeting [1]. This is what the doc is trying to tell us with "If one or two more arguments are provided, c and d are bound to them respectively; any arguments after the first four are collected into a list and e is bound to that list." As happens to Lars, to me this snippet seems to be as clear as it gets. But there seems to be something you are stumbling over. Since we can't see it, it's on you to open our eyes :) How could that be put more clearly? Cheers [1] That's what "keyword arguments" are for. Emacs lisp doesn't come "natively" with keyword arguments, but this being a Lisp, they just can be "made" (cf. the CL library for one implementation). - t --_000_AM0PR06MB6577E3D461AC55FBA72BB37496D60AM0PR06MB6577eurp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
It Is flera f=F6r me hos it work. What I am saying is tha= t docs does not say that we can't omit "optional" c or d when &am= p;rest is used. In the examples you are illustrating with, one can't omit s= ay d and write (foo a b  c  e), both c and d are required, so user has to pass explicitly at least nil if not d is provided: (foo a b= c nil e)

Documentation is talking about being able to omit either = optional or rest arga, but does not touch on the case when one pass both op= tional and rest together. In that case optional is not optional any longer.=

I don't understand why is it so difficult to see what I a= m talking about :-).

Anyway: Happy new year's eve and all best in 2021!


-------- Originalmeddelande --------
Fr=E5n: tomas@tuxteam.de
Datum: 2020-12-31 12:27 (GMT+01:00)
Till: emacs-devel@gnu.org
=C4mne: Re: Docs for &optional and &rest arguments together

On Thu, Dec 31, 2020 at 07:55:26AM +0000, arthur m= iller wrote:
> I don't read it says both c and d are required when &rest is also = used.

You just have to squint the other way .-)

They are not "required". They are provided -- in the call. It's j= ust
that c is served first, d next, and all the rest (if any) goes to e:

  (defun foo (a b &optional c d &rest e))
    ...)

If called like

  (foo 42)
        =3D> error (missing arg
  (foo 42 55)
        =3D> a -> 42 b -> 55 c = -> nil d -> nil e -> nil
  (foo 42 55 67)
        =3D> a -> 42 b -> 55 c = -> 67 d -> nil e -> nil
  (foo 42 55 67 92)
        =3D> a -> 42 b -> 55 c = -> 67 d -> 92 e -> nil
  (foo 42 55 67 92 117)
        =3D> a -> 42 b -> 55 c = -> 67 d -> 92 e -> (117)
  (foo 42 55 67 92 117 122)
        =3D> a -> 42 b -> 55 c = -> 67 d -> 92 e -> (117)
  (foo 42 55 67 92 117 122 131)
        =3D> a -> 42 b -> 55 c = -> 67 d -> 92 e -> (117 131)
  ...

Thing is, when calling the function you have /no way/ to express
which arg you are targeting [1]. This is what the doc is trying
to tell us with

  "If one or two more arguments are provided, c and d are
   bound to them respectively; any arguments after the first
   four are collected into a list and e is bound to that list.&qu= ot;

As happens to Lars, to me this snippet seems to be as clear as
it gets. But there seems to be something you are stumbling over.
Since we can't see it, it's on you to open our eyes :)

How could that be put more clearly?

Cheers

[1] That's what "keyword arguments" are for. Emacs lisp
   doesn't come "natively" with keyword arguments, but<= br>    this being a Lisp, they just can be "made" (cf. the<= br>    CL library for one implementation).

 - t
--_000_AM0PR06MB6577E3D461AC55FBA72BB37496D60AM0PR06MB6577eurp_--