From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Blake Shaw Newsgroups: gmane.lisp.guile.user Subject: SD4F: (exist? procedure-**maximum**-arity) Date: Wed, 29 Dec 2021 08:23:09 +0700 Message-ID: <874k6stdaa.fsf@nonconstructivism.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14430"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Dec 29 02:23:53 2021 Return-path: Envelope-to: guile-user@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 1n2Nh2-0003c9-PC for guile-user@m.gmane-mx.org; Wed, 29 Dec 2021 02:23:53 +0100 Original-Received: from localhost ([::1]:59200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2Nh1-0000Ys-4Z for guile-user@m.gmane-mx.org; Tue, 28 Dec 2021 20:23:51 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2Ngo-0000YU-HS for guile-user@gnu.org; Tue, 28 Dec 2021 20:23:39 -0500 Original-Received: from out1.migadu.com ([91.121.223.63]:63529) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2Ngm-0003CE-5O for guile-user@gnu.org; Tue, 28 Dec 2021 20:23:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nonconstructivism.com; s=key1; t=1640741012; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pOCTL4ycAPhFpEKmheQFyWpb6g8y/vbqfuoYt66PJZQ=; b=gyNwUXP5SESikAli2XuAO/nX5y1KUpNspjdyzHE0RhLNFRbNFvtih8kBlock49bwAcMxR1 LYyOY2VsDYXXcEfZEJJwVW2WnOAhilN+T45RYXL0cdT6sjlJ7ArHwIFGll5Bm4SHcveEWm 29GBe3yiFX186RljueXTskm7wC312oo= Gcc: nnimap+imap.migadu.de:sent.2021 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: nonconstructivism.com Received-SPF: pass client-ip=91.121.223.63; envelope-from=blake@nonconstructivism.com; helo=out1.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17926 Archived-At: Hiya Guilers, I've just started Sussman & Hanson's new book "Software Design for Flexibility" and am trying to translate one of the functions from MIT-Scheme to Guile: #+BEGIN_SRC scheme (define (get-arity proc) (or (hash-table-ref/default arity-table proc #f) (let ((a (procedure-arity proc))) ;arity not in table (assert (eqv? (procedure-arity-min a) (procedure-arity-max a))) (procedure-arity-min a)))) (define arity-table (make-weak-key-hash-table)) #+END_SRC So far this has lead me to these associations: |------------------------------+--------------------------+-------------------------| | MIT | Guile | Comments | |------------------------------+--------------------------+-------------------------| | procedure-arity | arity | | |------------------------------+--------------------------+-------------------------| | hash-table-set! | hashq-set! | possibly =hash-set!= | |------------------------------+--------------------------+-------------------------| | hash-table-ref/default | hashq-ref | possibly =hash-ref= | | | | or =hash-get-handle= | |------------------------------+--------------------------+-------------------------| | make-key-weak-eqv-hash-table | make-weak-key-hash-table | ∃(module) w/eqv-hash? | | | | think I saw it before | |------------------------------+--------------------------+-------------------------| | assert | assert | in (rnrs base) | | | &assertion | + (ice-9 exceptions) | | | assert-macro | + in (debugging assert) | |------------------------------+--------------------------+-------------------------| | procedure-arity-min | procedure-minimum-arity | | resulting in this translation of the function: #+BEGIN_SRC scheme (define (get-arity proc) (or (hashq-ref arity-table proc #f) (let ((a (arity proc))) (assert (eqv? (procedure-minimum-arity a) (**procedure-minimum-arity** a))) (procedure-minimum-arity a)))) #+END_SRC So now I'm just left with figuring out a function for getting the **maximum**[1] arity of a procedure, but I'm unsure how to go about this. I'm a sorta-new schemer and a very new guiler, so I'm unsure where to look... any advice would be appreciated![2] Thanks & happy hacking, Blake [1] double earmuffs to emphasize its a function I need but dont have [2] there is this inquiry already posted, but there was no conclusion https://mail.gnu.org/archive/html/guile-user/2021-05/msg00044.html -- “In girum imus nocte et consumimur igni”