From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Xiyue Deng Newsgroups: gmane.emacs.bugs Subject: bug#67669: 29.1; Drop text suggesting using `and' to replace `if' Date: Fri, 08 Dec 2023 01:07:27 -0800 Message-ID: <87v89983lc.fsf@debian-hx90.lan> References: <87v89buhpl.fsf@debian-hx90.lan> <83sf4e34s8.fsf@gnu.org> <87r0jytm58.fsf@debian-hx90.lan> <83a5qm2u8v.fsf@gnu.org> <87fs0ducme.fsf@debian-hx90.lan> <83v89928xe.fsf@gnu.org> <87bkb1u6tv.fsf@debian-hx90.lan> <83plzh225a.fsf@gnu.org> <8734wdu4t5.fsf@debian-hx90.lan> <83o7f11a9f.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3072"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 67669@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 08 10:08:50 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1rBWqo-0000c8-NB for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 08 Dec 2023 10:08:50 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBWqY-0008Sm-Jw; Fri, 08 Dec 2023 04:08:35 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBWqT-0008SS-6R for bug-gnu-emacs@gnu.org; Fri, 08 Dec 2023 04:08:29 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBWpp-0006ZU-0G for bug-gnu-emacs@gnu.org; Fri, 08 Dec 2023 04:08:28 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rBWq1-0005XI-QX for bug-gnu-emacs@gnu.org; Fri, 08 Dec 2023 04:08:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Xiyue Deng Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 08 Dec 2023 09:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67669 X-GNU-PR-Package: emacs Original-Received: via spool by 67669-submit@debbugs.gnu.org id=B67669.170202646921233 (code B ref 67669); Fri, 08 Dec 2023 09:08:01 +0000 Original-Received: (at 67669) by debbugs.gnu.org; 8 Dec 2023 09:07:49 +0000 Original-Received: from localhost ([127.0.0.1]:43811 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rBWpp-0005WP-1d for submit@debbugs.gnu.org; Fri, 08 Dec 2023 04:07:49 -0500 Original-Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:56386) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rBWpn-0005W5-PL for 67669@debbugs.gnu.org; Fri, 08 Dec 2023 04:07:48 -0500 Original-Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6ce26a03d9eso1402782b3a.0 for <67669@debbugs.gnu.org>; Fri, 08 Dec 2023 01:07:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702026449; x=1702631249; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=M4wCOUmihSukDlDAW9EsMfVGKwF5yq92wyAGny3ADOQ=; b=a/g0ObUki2bjEYmUsyJ0Xm9AGbB2X7rJCSnJFOTOpjjJ8NiVY+xp9etQQS0vyOHGdS 12ViG6rsVPaVoW06wrLF86detW/0T3WEfTb0FL1Ulck9/1tKvK5cwV1W1P77Kmg7B6iC e92BWMlHH7BMi9sahpPp55dn6GJWUXVk7TlsFLBalqR7+7E/T6hQdV9wNS+I5Yflocdr 2mscS0zfsnRUb4DSrVqCtrv4W8P3P1LjK9xgb+uCeW0Nk+O0KlRn0FTY8Kg6HrRau/cc nu6WnpAJ1MIUNTHvw+twmy7fZmrZq2WR80PqBqCZ8NzoFpozaTms9dS0QILGWkjQDG2x n51w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702026449; x=1702631249; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=M4wCOUmihSukDlDAW9EsMfVGKwF5yq92wyAGny3ADOQ=; b=bhEd3oFWFRLkTjxHkiloRcCnZDztxovgoXsdVvgiwTot7VU6jh2E7FrRQv47DiouZU fMeg9VydGm7ciIjetDuXFewZnp4yosww4P5c2lxapK43armDqWOxbiuay3UF0tLo4E1D Sc7nUdkv+v7qMrdWQoEnHUWM76mObl7BlupjSBCVUut6vCJj2l4Y7sTx9x2su2MMlDev VnfIu2jBhKFobCCIvkADww4t0Vf+sq3xjjAkDq44Ku/kFj7NnBs8Tk6tDZxrAbNpnbCQ Aea+1oBZc09CoyW/awXOQlIe1Q8qWhayrJI60SGl5N9hTwvX488DKCwTWYFDHcr2go8j ueog== X-Gm-Message-State: AOJu0YzojdgaYQYfE+pNGEr6MVP8eQ+Dacnt34RubPe28qOvdSScw5AO JvB9pqEUiogvXCELjIFKrXSabYnlwaTTZQ== X-Google-Smtp-Source: AGHT+IF8ihekkpOuGk29nvWZM4EkFmy5ghqhCVx0KOHP6cGV95hu4wKOZj5ybgXxMDXngYeEoKC2pw== X-Received: by 2002:a05:6a20:3941:b0:18f:97c:926c with SMTP id r1-20020a056a20394100b0018f097c926cmr3936417pzg.81.1702026448554; Fri, 08 Dec 2023 01:07:28 -0800 (PST) Original-Received: from debian-hx90 (2603-8000-a400-0cdc-05b7-1692-5cbe-65ea.res6.spectrum.com. [2603:8000:a400:cdc:5b7:1692:5cbe:65ea]) by smtp.gmail.com with ESMTPSA id z1-20020aa785c1000000b006ce8278097dsm1107703pfn.200.2023.12.08.01.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 01:07:28 -0800 (PST) In-Reply-To: <83o7f11a9f.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 08 Dec 2023 08:25:16 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:275742 Archived-At: Eli Zaretskii writes: >> From: Xiyue Deng >> Cc: 67669-done@debbugs.gnu.org >> Date: Thu, 07 Dec 2023 12:37:58 -0800 >> >> Eli Zaretskii writes: >> >> >> I was referring to whether we care about and use the result of the >> >> statement/function call. In `and' we do, in `if' we don't and we just >> >> use the side effect. >> > >> > But that's not true. 'if' does return a value, and we do use it. >> > Consider this random example: >> > >> > (defsubst posn-area (position) >> > [...] >> > (let ((area (if (consp (nth 1 position)) >> > (car (nth 1 position)) >> > (nth 1 position)))) >> > (and (symbolp area) area))) >> > >> > Here we bind 'area' to the value returned by 'if'. >> >> Well if we use `if' with else then yes. > > No. When 'if' has no 'else' clause, and the test fails, 'if' returns > nil. This is used in many places in our code. Like this: > > (let (baz) > (setq foo (concat "bar" (if (stringp baz) baz)))) > => "bar" > > Here 'if' returns nil, and we use the feature of 'concat' to ignore > nil arguments. Ah I see. So it looks like in Elisp `and' and `if' are actually used interchangeably. This was not very obvious at first for me who's more familiar with other imperative languages. TIL. Thanks! -- Xiyue Deng