From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Skyler Ferris via "Developers list for Guile, the GNU extensibility library" Newsgroups: gmane.lisp.guile.devel Subject: Re: yeRemoving program-arities export Date: Thu, 09 Jan 2025 09:53:24 +0000 Message-ID: <4DvFlbTmUeeHimWXHamdSYjxV23C_JyK4VPXP8y4YnHB4-GGaxYIP6V-3rfMImcyOzpYWr1b52NcxE4R0n_we5pfEsZ1XV4Cp77pWfwKH7M=@skyler-ferris.me> References: <20250105190726.xW7S2D00948vBLV06W7S96@albert.telenet-ops.be> <87ldvlawg0.fsf@web.de> Reply-To: Skyler Ferris 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="7195"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "Skyler Ferris via \"Developers list for Guile, the GNU extensibility library\"" , Maxime Devos To: "Dr. Arne Babenhauserheide" Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Thu Jan 09 10:54:08 2025 Return-path: Envelope-to: guile-devel@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 1tVpEt-0001fP-TB for guile-devel@m.gmane-mx.org; Thu, 09 Jan 2025 10:54:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVpEP-0002cn-LS; Thu, 09 Jan 2025 04:53:37 -0500 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 1tVpEN-0002cU-W7 for guile-devel@gnu.org; Thu, 09 Jan 2025 04:53:36 -0500 Original-Received: from mail-40135.protonmail.ch ([185.70.40.135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tVpEJ-0004r6-VP for guile-devel@gnu.org; Thu, 09 Jan 2025 04:53:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skyler-ferris.me; s=protonmail2; t=1736416409; x=1736675609; bh=OH8NrdoDRmUkQdwL7w2IZbAyENRJk4at731hepCpD2U=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=wJmNh0y/zhGsWuMFrqqWUX8Sq6UJbRrWrA21ll0NB9VpTE0xUdcPfmpEAL8iJNb1T UZu+Rx19z6TpaWS4c+GfMLgsOKwYYXaqUTrCLsH5QzrtJhzF2jFzkByEMz/zyxnl45 ndT4b5SsRkVP/82Ivv0xgJoMbJJsvLhPz//uTSf4en7+d+9NyYYtGkSc1bFgAceWB+ cZBb8KNosYE9j16aGD2nezdLY91FlRmd33/vN/Ew0F4eDfD5uCRhdKi3i8rxWwTV/y cjnSU6IfA9qZmDdg0DnY/SGW/PhNEOWeY9lOkthScOqCZVNqLwER9cQkFhee7ieCR8 gyAyHenvAbTNw== In-Reply-To: <87ldvlawg0.fsf@web.de> Feedback-ID: 112111505:user:proton X-Pm-Message-ID: 22d620ae24155d6b49dde5abe9ad128216d9de2a Received-SPF: pass client-ip=185.70.40.135; envelope-from=dev@skyler-ferris.me; helo=mail-40135.protonmail.ch 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22866 Archived-At: > Given that the program-arity / program-arities is documented, the more > pressing problem is that programs using it would be broken right now. > People may be holding off from updating Guile because they don=E2=80= =99t have > the time to investigate breakage in programs that are working perfectly > fine in the old version. Which is the typical case for useful tools. >=20 > The worst user experience is seeing a working program break when > updating a dependency: if the docs are wrong, you=E2=80=99re still in the > context of your tool, but if it breaks on update, all that context has > been flushed out already =E2=80=94 often years ago. Fair point. A lot of projects transition APIs by providing deprecation noti= ces, but I am not aware of Guile doing that for this API. This is a strong = argument against removing it immediately. =20 > Is it viable to wrap the procedure and exactly preserve the API, so > existing programs keep working? If it=E2=80=99s a bit slower, that should= not > cause pain (because hardware and Guile got faster in the meantime) but > it should not break. I believe this is possible so long as these programs do not need to access = arity information from procedures which pass the "primitive-code?" predicat= e. I am not sure what this predicate is actually testing. The implementatio= n of "is_primitive_code" in "libguile/programs.c" is looking at a list of "= code_arena" structs which I am not familiar with. The implementation of "fi= nd-program-arities" in "module/system/vm/debug.scm" is searching through lo= aded ELF images to find the one which contains the given program (and alway= s fails to find one when the program passes "primitive-code?"). Based on th= e commit message in 27337b6373954e1a975d97d0bf06b5c03d65b64d, it seems like= this behavior is expected. What puzzles me the most is that functions defi= ned at the scheme level in the same file are not consistent in whether or n= ot they are primitive. For example, "count" in SRFI 1 is primitive but "unz= ip1" is not. My best guess is that it has something to do with JIT compiled= functions, but that truly is a guess. Also, I have not looked at the output of "arity:start" and "arity:end". I'm= not sure how I would go about testing these, but it looks like the struct = returned from "find-program-arities" contains the same information. This pr= ocedure also has an optional "context" argument; I have only tried using th= e default value. This is the code I'm currently using to try things out. The final line prod= uces a lot of output, you can just comment it out for a quieter script. (use-modules (system vm debug) (system vm program)) (define program-module (resolve-module '(system vm program))) (module-set! program-module 'program-arities (compose find-program-arities program-code)) (module-set! program-module 'arity:start arity-low-pc) (module-set! program-module 'arity:end arity-high-pc) (module-set! program-module 'arity:nreq arity-nreq) (module-set! program-module 'arity:nopt arity-nopt) (module-set! program-module 'arity:rest? arity-has-rest?) (module-set! program-module 'arity:kw arity-keyword-args) (module-set! program-module 'arity:allow-other-keys? arity-allow-other-keys= ?) (define* (uut req #:optional opt0 opt1 #:key key0 key1 key2 #:allow-other-keys #:rest rest) (cons* req opt0 opt1 key0 key1 key2 rest)) (define arities (program-arities uut)) (define arity (program-arity uut #f)) (format #t "Number of arities: ~s~%" (length arities)) (format #t "Required arguments: ~s~%" (arity:nreq arity)) (format #t "Optional arguments: ~s~%" (arity:nopt arity)) (format #t "Rest argmuent? ~s~%" (arity:rest? arity)) (format #t "Keyword arguments: ~s~%" (arity:kw arity)) (format #t "Other keys? ~s~%" (arity:allow-other-keys? arity)) (newline) (define uut (case-lambda ((single) single) ((du o) (list du o)) ((tr i o) (list tr i o)))) (format #t "Arities from a case-lambda: ~s~%" (length (program-arities uut)= )) (newline) (define (generate-arity-trier proc) (lambda (sym var) (let ((val (variable-ref var))) (when (procedure? val) (format #t "Arities of ~s: ~s~a~%" sym (and=3D> (proc val) length) (if (primitive-code? (program-code val)) " (primitive)" "")= ))))) ; use any of the below procedures in module-for-each line at the end (define try-program-arity (generate-arity-trier program-arities)) (define try-program-arguments-alist (generate-arity-trier program-arguments= -alist)) (define (check-for-inconsistency sym var) (let ((val (variable-ref var))) (when (and (procedure? val) (program-arities val) (primitive-code? (program-code val))) (format #t "~s is inconsistent!~%" sym)))) (module-for-each try-program-arity (resolve-interface '(srfi srfi-1)))