From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: pietru@caramail.com Newsgroups: gmane.emacs.help Subject: Re: Optional Arguments Date: Mon, 7 Dec 2020 18:51:34 +0100 Message-ID: References: <20201207130630.GA10719@tuxteam.de> <20201207155108.GC15617@tuxteam.de> 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="39664"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help Gnu Emacs To: tomas@tuxteam.de Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 07 19:12:20 2020 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 1kmKzk-000ABf-GW for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 07 Dec 2020 19:12:20 +0100 Original-Received: from localhost ([::1]:39458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmKzh-0005Rk-QH for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 07 Dec 2020 13:12:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmKfo-0005iQ-FZ for help-gnu-emacs@gnu.org; Mon, 07 Dec 2020 12:51:44 -0500 Original-Received: from mout.gmx.net ([212.227.17.20]:47115) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmKfl-0002lj-MX for help-gnu-emacs@gnu.org; Mon, 07 Dec 2020 12:51:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1607363494; bh=la9dczXjctRrr3cSHJ7t9rYUBHkaTm4+l+JUU4jnjMA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=L/C6UYGiOLKcH68L5/AQlpHk02RWXKb9X3GqSVr2lM4MdGPLyRTB/WvZjVUTLPXYn TC+Cl95Ur/BOXXvDKC6ac3wyAgPv3t2959edL347xW4wnOcLaze+ZsNZticJjmjgfo csloQhJqf/RoF5ZYvb9GUTba76a82pFucz8/+xXA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [213.165.168.94] ([213.165.168.94]) by web-mail.gmx.net (3c-app-mailcom-bs11.server.lan [172.19.170.179]) (via HTTP); Mon, 7 Dec 2020 18:51:34 +0100 Importance: normal Sensitivity: Normal In-Reply-To: <20201207155108.GC15617@tuxteam.de> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:IjKNaIlYt9JWCYWPlaWtzFdf1+SiBkaE0Hr8Lkn0a+KwDKomuwGItvKWTDE482oVjC+uT VKITq7b4Z/3tdFmQtqitkWs495cJxOzgMpvNZcM012MXAzsvdeR4ixYHBwc/636CwCa5M9KRufsh ltrAa7R7zzIq+wd5wkcIx+wjTt4Mvb4XfLISEltuBtrmb9fw0RfUvkhFrp6uwp+0ML2WMkUm+7Ow VAt4fWfMTx3+1dPCTPQHM1ULAQr2aPCYpCQFpiDisQ0wyQBncxif6S+tJWW4FtAf7+zx5UX9ou3L T0= X-UI-Out-Filterresults: notjunk:1;V03:K0:LOMC1Cwdxo4=:h6MAiPUa8iJFArT6HH5IRr PMxoKe9A+0z6kZvUoga+GUTZbF59DvhLFigb+h8LEjUdY/RRkuqEXEDvwflhjABCKCc7JODoQ 5ah8ec0xllZxIa+C/CDSbB8+UutHYiQytvnx1FGXDFJioYxwaXgG457/sSrK36S10tyARI10K SKXrJPdDGo7+zD2rb9BOQ/MT6XRt1lfN4giEzZh8YmuovPJSKh4lCXVAFdQidihs33qiQoVcN 2u4/UODK1dx2r4U5fP6mCHw/h3P9R1W84lHd7ggutafEENyeyp5jcRnUDOZVSynMWWZe5BDno NwszJmRfkF30fdvKan2r9eZNmXr3MOyWP5sZIFuPoG9jaL9ADRrGz5uUXQIEdLN6iVMixs7CZ EfIs/2EQl2R8pr2D33K/La3QZKZYqQLGFB+LNY90uC7fa7cZn6rKA9TK6woHMI1WneLFVW/WK e7nfe/Qatv4IWyuv8Wuq7FYdKiJl80m+pXP976twt3mAVOQ0Jdq/ssaxBiGPlyULEX3hiqjid WHPl/OWQ7pfnDpBeGo+ynu/SuuE7BAiG+ZngkpfwFZ0NE3qJHwCv83DkmrIU4FQLBEvRgLRA2 cxOLwh8GtmqVQ= Received-SPF: pass client-ip=212.227.17.20; envelope-from=pietru@caramail.com; helo=mout.gmx.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 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" Xref: news.gmane.io gmane.emacs.help:126158 Archived-At: > Sent: Monday, December 07, 2020 at 4:51 PM > From: tomas@tuxteam.de > To: pietru@caramail.com > Cc: "Help Gnu Emacs" > Subject: Re: Optional Arguments > > On Mon, Dec 07, 2020 at 04:06:13PM +0100, pietru@caramail.com wrote: > > [...] > > > How can one get computed values from a function then? > > Either you return it (in your case, e.g. by returning a pair) > > (cons ma mb) Because by default, a function returns the value of the last expression evaluated as the return value. Correct? > or (less preferable) by modifying variables "outside" of the > function. You have to take carefully into account what kind > of binding the program runs under, or to use "global" (in > the sense of program scope: buffer-local variables count as > global here) variables, and you have a very good Petri dish > for all sort of nasty bugs ;-) > > Under lexical binding, this, for example, would do: > > (let ((ma 0) > (mb 0)) > > (defun foo () > (setq ma 5) > (setq mb 7)) > > (foo) > (message "ma: %d mb: %d" ma mb)) > > (the function `foo' "sees" the variables `ma', `mb' set up in > the enclosing scope). Only recommended for small, tightly knit > snippets: the (human) reader should be able to "see" that too. > > Cheers > - t >