From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: tpeplt Newsgroups: gmane.emacs.help Subject: Re: Difference between cons and dot Date: Sat, 20 Apr 2024 12:08:04 -0400 Message-ID: <8734rgaufv.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20677"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Heime via Users list for the GNU Emacs text editor To: Heime Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 20 18:08:46 2024 Return-path: Envelope-to: geh-help-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 1ryDGf-0005Bb-Kp for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 20 Apr 2024 18:08:45 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ryDG8-00078i-EY; Sat, 20 Apr 2024 12:08:12 -0400 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 1ryDG6-00078K-Qs for help-gnu-emacs@gnu.org; Sat, 20 Apr 2024 12:08:10 -0400 Original-Received: from mail-qv1-xf29.google.com ([2607:f8b0:4864:20::f29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ryDG5-0007wW-4N for help-gnu-emacs@gnu.org; Sat, 20 Apr 2024 12:08:10 -0400 Original-Received: by mail-qv1-xf29.google.com with SMTP id 6a1803df08f44-69b514d3cf4so25191826d6.0 for ; Sat, 20 Apr 2024 09:08:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713629286; x=1714234086; darn=gnu.org; h=content-transfer-encoding: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=OoQq4z8SAaDsYc2MbpvARVWlEcKBnwbq5jv5A6LIAR4=; b=dQFdPEyxg7QTaxkomZQe7uyy1wINfYkIrwTvr0FPQMda7gJfjF3eaSZiLSODLTZNmr jlJD9nrGvnnhOuXn55d+SgGQkRY+MHe6msgp7/os/voFSbP9PVdfKdwrO9rFiTn7hBl0 HhXttd9kRwc+f7ne3U6Aoz3QATleb7kkwGKY6mxhRQdiYWhSoEzbPH9whp+9Kq6St5ZS ROWnD3zIZAfGZi1dy/EzJtkrb56DpAoB7ZNwAYiD9HyMvFxJuiN//EHwVweAZwwcFwt8 +4JAecoMQCzRJeENX37TmzGg0xnYS+kgKEL1/KCE2Nbi/rdlLrNrTvT2mTkbOz5KJr0j 7Fkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713629286; x=1714234086; h=content-transfer-encoding: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=OoQq4z8SAaDsYc2MbpvARVWlEcKBnwbq5jv5A6LIAR4=; b=YLNblX2cvKfF0UAOI/+FtpAO0sTk8Qfp8vmPpgY+bNpHn1tsQ0/1Rw98nYUBuEztoB e6LMestBSyQ8ef/ZUaqUMsexeWrdbqfACFkMRmrosW48jZDeuar6BXrk8zOq3+NsuwFV 4XG25JmajqzN0Ph3ZBda/TF67pKpundkmv5VF2K7IDOHcsCGZFGgg5x88crve5u1FTkl 20dhFoueU/SkEJ0Ma4nPFGKSy9fAUei+r/eYF+V6iKM45PWWqEGPVNZf6BY1k6LJkUv3 EMKI6K1svoUQD4frgIiiuoIGSbMAUKDztFml8D7FFHV/e6/1nRd0gqbJtqxTOdfh4uV1 iSkw== X-Gm-Message-State: AOJu0YyJ/q7FWOTv32Avged1oZu6F+/JFc9SjVFc1BnBmA/I7Gv7XDxq fPrAzRXTu04SmeLPz/mbfRPVTmodl9eYHwq3K4fxHJjRuOPpfQgX X-Google-Smtp-Source: AGHT+IFML51uKLafkNBD4HdrvWFFHZDHz245fopGgjX8J9rkGtXps+OIyZk+tpZis/u0HbmmHRoNhQ== X-Received: by 2002:ad4:4388:0:b0:6a0:5622:f206 with SMTP id s8-20020ad44388000000b006a05622f206mr5802936qvr.50.1713629285682; Sat, 20 Apr 2024 09:08:05 -0700 (PDT) Original-Received: from t530.local ([2600:8806:a801:d4c0:1bb4:1840:c99c:2b9d]) by smtp.gmail.com with ESMTPSA id w16-20020a0cfc50000000b0069b69c5f077sm1760664qvp.102.2024.04.20.09.08.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Apr 2024 09:08:05 -0700 (PDT) In-Reply-To: (Heime's message of "Sat, 20 Apr 2024 12:20:20 +0000") Received-SPF: pass client-ip=2607:f8b0:4864:20::f29; envelope-from=tpeplt@gmail.com; helo=mail-qv1-xf29.google.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:146406 Archived-At: Heime writes: > Am adding an elemnt to an alist using either the cons or dot method. > Have noticed that with cons I do not need to call list=20 > > Thusly=20 > > (push (cons kfrz lnum) tema-lugar) > > rather than > > (push '(cons kfrz lnum) tema-lugar) > > But with the dot method I have to use=20 > > (push '(kfrz . lnum) tema-lugar) > > and not=20 > > (push (kfrz . lnum) tema-lugar) > > What is the reason for this difference ? 1. The reason for the difference is that, in Lisp, a function=E2=80=99s arg= uments are expressions that are evaluated to obtain a value before the function is called. And your two examples yield different values when the argument expressions are evaluated. So, the expression =E2=80=98(cons kfrz lnum)=E2=80=99 is evaluated to ob= tain a value before the function =E2=80=98push=E2=80=99 is called. And the expressio= ns =E2=80=98kfrz=E2=80=99 and =E2=80=98lnum=E2=80=99 are evaluated before the function =E2=80=98cons= =E2=80=99 is called, (Which means that you probably meant to write =E2=80=98(cons 'kfrz 'lnum)=E2=80= =99 instead). If the expression =E2=80=98(cons 'kfrz 'lnum)=E2=80=99 is evaluated, it = yields the value =E2=80=98(kfrz . lnum)=E2=80=99, which is the value passed to =E2=80=98p= ush=E2=80=99. Likewise, the expression (kfrz . lnum) is evaluated for a value before =E2=80=98push=E2=80=99 is called. In order to evaluate (kfrz . lnum), t= he two arguments =E2=80=98.=E2=80=99 and =E2=80=98lnum=E2=80=99 would need to b= e evaluated before calling the function =E2=80=98kfrz=E2=80=99. Of course, you likely did not mean for= =E2=80=98kfrz=E2=80=99 to be a function. Rather, you meant for =E2=80=98push=E2=80=99 to receive the v= alue (kfrz . lnum), which is what (cons 'kfrz 'lnum) returns when evaluated. It is also what the expression '(kfrz . lnum) returns when it is evaluated. The apostrophe or single-quote in the expression is a Lisp shorthand for the =E2=80=98quote=E2=80=99 function (C-h f quote for more detail). So,= you could write: (push (quote (kfrz . lnum)) tema-lugar) (quote (kfrz . lnum)) yields the same value as '(kfrz . lnum). Enter each of these two expressions after M-: if you would like to see this confirmed. 2. If you have read the "Introduction to Emacs Lisp", you will want to read parts of it again to increase your understanding of Lisp. In particular, read parts of the chapter on List Processing: (info "(eintr) List Processing") including (info "(eintr) Evaluation") (info "(eintr) Arguments") (info "(eintr) Summary") --=20 The lyf so short, the craft so long to lerne. - Geoffrey Chaucer, The Parliament of Birds.