From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ricardo Wurmus Newsgroups: gmane.lisp.guile.bugs Subject: bug#46014: (define (thunk) (lambda (x) x)) should be a compile error? Date: Thu, 21 Jan 2021 23:27:23 +0100 Message-ID: <878s8mkjsk.fsf@elephly.net> References: <87h7nb3v0g.fsf@dismail.de> <87bldil7fo.fsf@elephly.net> <87eeie2gs1.fsf@dismail.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="29206"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.13; emacs 27.1 Cc: 46014@debbugs.gnu.org To: Joshua Branson Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Thu Jan 21 23:28:08 2021 Return-path: Envelope-to: guile-bugs@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 1l2iQx-0007Te-S2 for guile-bugs@m.gmane-mx.org; Thu, 21 Jan 2021 23:28:07 +0100 Original-Received: from localhost ([::1]:55854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l2iQw-0004Jd-N3 for guile-bugs@m.gmane-mx.org; Thu, 21 Jan 2021 17:28:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2iQs-0004Io-6A for bug-guile@gnu.org; Thu, 21 Jan 2021 17:28:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48067) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l2iQr-0006rw-UR for bug-guile@gnu.org; Thu, 21 Jan 2021 17:28:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l2iQr-0003vs-QS for bug-guile@gnu.org; Thu, 21 Jan 2021 17:28:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ricardo Wurmus Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 21 Jan 2021 22:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46014 X-GNU-PR-Package: guile X-Debbugs-Original-Cc: bug-guile@gnu.org, 46014@debbugs.gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.161126806115084 (code B ref -1); Thu, 21 Jan 2021 22:28:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Jan 2021 22:27:41 +0000 Original-Received: from localhost ([127.0.0.1]:59611 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l2iQX-0003vE-4e for submit@debbugs.gnu.org; Thu, 21 Jan 2021 17:27:41 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:50000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l2iQV-0003v1-Q5 for submit@debbugs.gnu.org; Thu, 21 Jan 2021 17:27:40 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2iQV-0004IL-Iy for bug-guile@gnu.org; Thu, 21 Jan 2021 17:27:39 -0500 Original-Received: from sender4-of-o51.zoho.com ([136.143.188.51]:21153) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2iQT-0006k2-LG for bug-guile@gnu.org; Thu, 21 Jan 2021 17:27:39 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1611268048; cv=none; d=zohomail.com; s=zohoarc; b=fHKXP1OhkvonRG51e/+9dYI/G+zqqRoa8AWliQb5948vliOh+Y0h2eVLEoEB9KFDx6+E0RmdGkoiL6txGdwLCfX58gXs5azK2sAy8bJ7y+1qhy+P0dFuOo4cQYI9SnVoCGZUjXHXzHehqm08S+nxC5Mlx/+y/0rjT/tN7CN3Iw0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611268048; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=2N5QHrEV0EVMPEgosi0ptgucn27TdjMiM4112dNvJdg=; b=a/1V4u1UrHse3Hs5wOm/9rKttNxVrgkeDpbca2rxej3DhrWXiqiWU85qEJ/Fjus6z+XpA6Ih/rJxk3uywEAaogtwtDzIWqSihE7cdHDyL5J4rxMfjsnnJniqDf8anKDYzXlpkFWxAFoMBoeKqiGOVH4KNoZti90+s0KrTvxgT7g= 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=1611268048; 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=2N5QHrEV0EVMPEgosi0ptgucn27TdjMiM4112dNvJdg=; b=WYTgme2L1VX3A425P8vnA2GtiF/2j6qUcQJ4ZDT1Sz7kV+PDguWh4ah+h/8HY8DE 1EA4KMXGRYi09VpBn+kDBd8wud/f7pbm4M8vww8QzVluwtPJwWWJ8n8B0PKY2nG8ZxQ Kp29GBqZs/P+ZrvmCC0/onyyxrQpO4QcUSQuIx0Y= Original-Received: from localhost (p54ad4e28.dip0.t-ipconnect.de [84.173.78.40]) by mx.zohomail.com with SMTPS id 1611268047063346.3233320606232; Thu, 21 Jan 2021 14:27:27 -0800 (PST) In-reply-to: <87eeie2gs1.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 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:9963 Archived-At: Hi Joshua, > When I look at > > #+BEGIN_SRC scheme > (define (thunk) > (lambda (x) > x)) > #+END_SRC [=E2=80=A6] > My thought is, this is clearly a mistake. This person needs to change > the above code. How is this clearly a mistake? The definition of =E2=80=9Cthunk=E2=80=9D a= bove is perfectly fine and also common. The above is equivalent to (define thunk (lambda () (lambda (x) x))) And that=E2=80=99s really okay and can be desired. The problem is not with this definition. If someone calls this wrongly, well, that=E2=80=99s a pro= blem with the caller. And Guile=E2=80=99s compiler does tell you that you are probably wrong in calling =E2=80=9Cthunk=E2=80=9D with an argument. Do I understand you correctly that you would like this warning to be an error instead? > Gotcha. Thanks for explaining! I suppose what I meant to say is, > should guile refuse to compile the above? In other languages, like C I > suppose, writing a function simultaneous with one and two arguments > would refuse to compile. The compiler would make you fix the code. Let me address this separately. In Scheme you *can* define a procedure that takes a different number of arguments. Here=E2=80=99s one example fro= m the manual: (define (make-accum n) (case-lambda (() n) ((m) (set! n (+ n m)) n))) (define a (make-accum 20)) (a) =E2=87=92 20 (a 10) =E2=87=92 30 (a) =E2=87=92 30 =E2=80=9Ccase-lambda=E2=80=9D specifies a procedure that can take arguments= in as many different shapes as there are clauses. Here there are two clauses: one for the case where no arguments are provided and another where one argument (bound to =E2=80=9Cm=E2=80=9D) is provided. Furthermore, you can see here that this is a higher order procedure, as =E2=80=9Cmake-accum=E2=80=9D takes an argument and returns a procedure (the case-lambda). Another example, also from the manual, is this: (lambda* (start #:optional (end (+ 10 start))) (do ((i start (1+ i))) ((> i end)) (display i))) This procedure takes one or two arguments. --=20 Ricardo