From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 21 08:57:07 2021 Received: (at submit) by debbugs.gnu.org; 21 Jan 2021 13:57:07 +0000 Received: from localhost ([127.0.0.1]:57135 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l2aSR-0003iC-9F for submit@debbugs.gnu.org; Thu, 21 Jan 2021 08:57:07 -0500 Received: from lists.gnu.org ([209.51.188.17]:36752) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l2aSP-0003hz-QR for submit@debbugs.gnu.org; Thu, 21 Jan 2021 08:57:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2aSP-0001Aa-Ec for bug-guile@gnu.org; Thu, 21 Jan 2021 08:57:05 -0500 Received: from sender4-of-o51.zoho.com ([136.143.188.51]:21163) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2aSN-0007gH-6q for bug-guile@gnu.org; Thu, 21 Jan 2021 08:57:05 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1611237410; cv=none; d=zohomail.com; s=zohoarc; b=DO5eVxRfk0q7HreifYFBsIRTklKfi87xzcHOj1csLVuoTWXBLzlKjAs63rpxgCXTRiivH6tDamhpZxrnz5UAhIHyvX7ebXiIZHpZmJ55VhmQglDKMsuFUu/pvwraZQA3WUi8fL8ayMIpMmtvGyWKcqGt0JZ6bqVNNhGvFquG/wQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611237410; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=RjEqPnrM9bA5r9kqhwiVYegLupvbeVtMnN9bFyCo5Lc=; b=PvWnxdUqKaKgjVs9yt7ZaZ8gomTMiM2eRLfJg+9E096xDX9V1kzBRH1ZblPESLvaYsTsX8g4S3ukE+4B5oJpmOo1XRnmNIdohgQdlzeUgHG+xB1+B7PLzce0+fv0YwgZujw6wmO/H62TSMVhjsnoayFwQsSqiiqvPHGO1jtqR+s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1611237410; s=zoho; d=elephly.net; i=rekado@elephly.net; h=References:From:To:Cc:Subject:In-reply-to:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=RjEqPnrM9bA5r9kqhwiVYegLupvbeVtMnN9bFyCo5Lc=; b=R3/J3Lh8GEIy7QfVcniDIQrodaqAV5n1q8XClCbr7v7dVq7dRn7jt0xPafqTQISB W0iLpioafMdp7Uz5AoOimZUIfQdEdgHFpGan/WWcXeT8ih5N7ORWqw00c5KoWratGqw y+S1tFPn78ArVEZhQzXZJQE0vpQVKJFYKQbgLXDE= Received: from localhost (p54ad4e28.dip0.t-ipconnect.de [84.173.78.40]) by mx.zohomail.com with SMTPS id 1611237408215914.4205729868123; Thu, 21 Jan 2021 05:56:48 -0800 (PST) References: <87h7nb3v0g.fsf@dismail.de> User-agent: mu4e 1.4.13; emacs 27.1 From: Ricardo Wurmus To: Joshua Branson Subject: Re: bug#46014: (define (thunk) (lambda (x) x)) should be a compile error? In-reply-to: <87h7nb3v0g.fsf@dismail.de> X-URL: https://elephly.net X-PGP-Key: https://elephly.net/rekado.pubkey X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC Date: Thu, 21 Jan 2021 14:56:43 +0100 Message-ID: <87bldil7fo.fsf@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Received-SPF: pass client-ip=136.143.188.51; envelope-from=rekado@elephly.net; helo=sender4-of-o51.zoho.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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: bug-guile@gnu.org, 46014@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Hi, > Consider this bit of simple code: > > #+BEGIN_SRC scheme > > (define (thunk) > (lambda (x) > x)) > > (thunk) ;; works ok, I guess. > (thunk "hello world!\n") ;; runtime error > > ;;; :1074:0: warning: possibly wrong number of arguments to `thunk' > ice-9/boot-9.scm:1669:16: In procedure raise-exception: > Wrong number of arguments to # > > Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. > #+END_SRC > > Guile will compile this program seemingly with no error. Guile will > correctly report at runtime that procedure '(thunk "hello world!\n")' > takes no arguments, but it's lambda accepts 1 argument. Would it be > possible to report this error at compile time? Would that be > advantageous? This is not a bug. What you call =E2=80=9Cthunk=E2=80=9D here is a procedu= re that returns a procedure. That=E2=80=99s very common and is often done to delay evaluation. It is in fact an error to call the procedure =E2=80=9Cthunk=E2=80=9D with a= n argument. It doesn=E2=80=99t matter that it happens to return a procedure that *can* = take an argument. The procedure it returns is just like any other value, though, and isn=E2=80=99t inspected any further. That said, it is not true that Guile will compile this without a complaint. I dumped your code snippet in a file foo.scm and compiled it: --8<---------------cut here---------------start------------->8--- guild compile foo.scm foo.scm:6:0: warning: wrong number of arguments to `thunk' wrote `/home/rekado/.cache/guile/ccache/3.0-LE-8-4.4/home/rekado/dev/gx/gwl= /foo.scm.go' --8<---------------cut here---------------end--------------->8--- Isn=E2=80=99t that exactly what you=E2=80=99re asking for? --=20 Ricardo