From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Damien Mattei Newsgroups: gmane.lisp.guile.devel Subject: =?UTF-8?Q?Re=3A_Making_code_compatible_with_different_versions_o?= =?UTF-8?Q?f_Guile=E2=80=94_=23=3Adeclarative=3F?= Date: Tue, 10 Sep 2024 14:41:58 +0200 Message-ID: References: <87plpfwenn.fsf@web.de> <20240907194646.9Vmm2D0052h9R1001VmmdK@baptiste.telenet-ops.be> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000c59dcb0621c333fc" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2221"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "Dr. Arne Babenhauserheide" , "guile-devel@gnu.org" To: Maxime Devos Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Tue Sep 10 14:42:50 2024 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 1so0Cn-0000Mq-SE for guile-devel@m.gmane-mx.org; Tue, 10 Sep 2024 14:42:49 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so0CO-00006A-FN; Tue, 10 Sep 2024 08:42:24 -0400 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 1so0CL-0008AN-Sv for guile-devel@gnu.org; Tue, 10 Sep 2024 08:42:22 -0400 Original-Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so0CD-0005aM-1z for guile-devel@gnu.org; Tue, 10 Sep 2024 08:42:14 -0400 Original-Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-7a99e4417c3so279037685a.1 for ; Tue, 10 Sep 2024 05:42:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725972131; x=1726576931; darn=gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zB5hgM8yXLzzJWzTbaeMT07cEo4RbEkRM9XQ4Gg9lS4=; b=g+Tcd6Cbppu/v5W2FBM0ONjSZLsEpw8SQl6zDJwIyLjECwtaBWT2jQmkyF6DAU5xjP qvJdxjWJmkuxaHxBL/Sg+YnItQSJFfooEOP7ZkxWEMA8vo2abO5o/BYqIaWIaAgnfi3+ gteGccQHJG+K1uX+x7TaqClNYMddbIp3r46GPzST3p3X/t4W3zTKDEp3Bkp5OQXMko9+ zt5MVfWBSpppFAiqhVu9ztyOrNYd7xCfONkQzcyxarL7LJAV1IGOa8UV5PaDqWQgzFyM W4Q4nwGgrD821/B4Uqz3Yekimn2MWVQcwrQJjOoO0hxrc5Mwmr7YGsFnkIPwqOQUcNBk TQ6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725972131; x=1726576931; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zB5hgM8yXLzzJWzTbaeMT07cEo4RbEkRM9XQ4Gg9lS4=; b=NysCJ4PeV2ZIhRQMQCCWzM3uVKqwSH0iZWIaw7tkKI8EGsdNZFRgk2UrrhkpMv/x2o VyJkUFCT/z77Es3uNMk2J+cJFEqHBdYq+nahMx8e9OuhRrAaKUlzEOJBRvSkfXkfIOyN 8b9013X+7HCvYfTtFbi1+Lue5oXlMD67rfS7/z4qcBfEFlq/QJ4J+a8Ca14VBjm95pYh lAYH6lVotqXp83scSdopm6KojR70FXMPRhHRMFOGRooDlIK/oSq5BOH9sHp3VgotTtxD eFbq4Ao2Np4zo9HJcIgnK1FQjzKIll8gGifUWcnuqT0KQBIRcQMZ/hyv0LGBsHkNBQsc ZjwQ== X-Forwarded-Encrypted: i=1; AJvYcCV49x4UwKcfmDL4AnjHbmfQKaYMgnQ8ECox0FYUS09JPFx3UwaaifMK/k5ixsaZjFl1lSxUhKx77dFyWw==@gnu.org X-Gm-Message-State: AOJu0Yw9sn0230YI+kVH5I3bhRY1smh+NyxC3/dIzbLCSD/IZvKpYysN nJtOpvVqXJ7qbraVRROThJliPkXdO6spB/wslygmfs3fQpLO8ofXDZLHa0HVDYb3MYNHwvnoFmU tkQxJjdCBZgjoE3oJ4ZUHyfEBGqs= X-Google-Smtp-Source: AGHT+IHJHClRYRENoDRiQT5hc2oJi7sLw1/JztmhEuMYT0VvzS1qvrjeHIM/lhFMBk6IGjBuoHt85lX9zVBG1giFhgs= X-Received: by 2002:a05:620a:489a:b0:7a9:a3f7:ef30 with SMTP id af79cd13be357-7a9a3f7f222mr1662772785a.45.1725972131189; Tue, 10 Sep 2024 05:42:11 -0700 (PDT) In-Reply-To: <20240907194646.9Vmm2D0052h9R1001VmmdK@baptiste.telenet-ops.be> Received-SPF: pass client-ip=2607:f8b0:4864:20::733; envelope-from=damien.mattei@gmail.com; helo=mail-qk1-x733.google.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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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:22679 Archived-At: --000000000000c59dcb0621c333fc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Sep 7, 2024 at 7:52=E2=80=AFPM Maxime Devos wrote: > > > > IIRC doing (set! some-variable some-variable) on the top-level on a > variable of the module makes the module non-declarative by default, but > please check the manual for details (there is some information on this, I > don=E2=80=99t recall the name of the section). > > > > In particular, I would expect > > > > (define (foo ...) ...) > > (set! foo foo) > > > > to have the desired properties (at least as far as replacing =E2=80=98foo= =E2=80=99 with an > updated version is concerned), both in past, present and future. > > > > (No comment on what the default _*should*_ be.) > > > probably i'm a bit out of context but this make me remember some code i had written when doing some sort of "overloading" of procedure or operator i use 'define' instead of 'set!' i think i tried set! if i remember well but it gave bad result, so my current code use 'define' : (define (create-overloaded-procedure orig-funct funct pred-list) (display "create-overloaded-procedure") (display " : pred-list =3D ") (display pred-list) (newline) (define old-funct orig-funct) (define new-funct (lambda args ;; args is the list of arguments ;;(display "new-funct: ") (display new-funct) (newline) ;;(display "new-funct : pred-list =3D ") (display pred-list) (newline) ;;(display "new-funct : args =3D ") (display args) (newline) (if (check-arguments pred-list args) ;;(begin ;;(display "new funct :calling:") (display funct) (newline) (apply funct args);) ;;(begin ;;(display "new funct :calling:") (display old-funct) (newline) (apply old-funct args))));) (display "funct: ") (display funct) (newline) (display "orig-funct: ") (display orig-funct) (newline) (display "old-funct: ") (display old-funct) (newline) (display "new-funct: ") (display new-funct) (newline) new-funct) i used (define old-funct orig-funct) to backup the function instead of set! and the code can only called by a macro at top-level of a file and i can not do this 'overloading' implementation with different scheme implementation (Kawa,Racket,R6RS...) i had to store the overloading data in an hash table in a global variable of a module that i probably export instead of redefining an existing function. --000000000000c59dcb0621c333fc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Sat, Sep 7, 2024 at 7:52=E2=80=AFPM Maxime Devos= <maximedevos@telenet.be&g= t; wrote:


=C2=A0

IIRC doing (set! some-variable some-variable) on the top-le= vel on a variable of the module makes the module non-declarative by default= , but please check the manual for details (there is some information on thi= s, I don=E2=80=99t recall the name of the section).

=C2=A0

In particular, I would expect<= u>

= =C2=A0

(define= (foo ...) ...)

(set! foo foo)

=C2=A0

to have the desired properties (at least as far as repla= cing =E2=80=98foo=E2=80=99 with an updated version is concerned), both in p= ast, present and future.

=C2=A0

(No comment on what the default _should_ be.)

=C2= =A0


probably i'm a bit out of = context but this make me remember some code i had written

when doing some so= rt of "overloading" of procedure or operator i use 'define= 9; instead of 'set!' i think i tried set! if i remember well but it= gave bad result, so my current code use 'define' :

(define (create-overloaded-procedure ori= g-funct funct pred-list)

=C2=A0 (display "create-overloaded-pro= cedure")
=C2=A0 (display " : pred-list =3D ") (display pr= ed-list) (newline)
=C2=A0 (define old-funct orig-funct)
=C2=A0 (defin= e new-funct (lambda args ;; args is the list of arguments
=C2=A0 =C2= =A0 =C2=A0;;(display "new-funct: ") (display new-funct) (newline)=
=C2=A0 =C2=A0 =C2=A0;;(display "new-funct : pred-list =3D "= ;) (display pred-list) (newline)
=C2=A0 =C2=A0 =C2=A0;;(display "= ;new-funct : args =3D ") (display args) (newline)
=C2=A0 =C2=A0 = =C2=A0(if (check-arguments pred-list args)
=C2=A0;;(begin
=C2= =A0 =C2=A0;;(display "new funct :calling:") (display funct) (newl= ine)
=C2=A0 =C2=A0(apply funct args);)
=C2=A0;;(begin
= =C2=A0 =C2=A0;;(display "new funct :calling:") (display old-funct= ) (newline)
=C2=A0 =C2=A0(apply old-funct args))));)
=C2=A0 = =C2=A0
=C2=A0 (display "funct: ") (display funct) (newline)=C2=A0 (display "orig-funct: ") (display orig-funct) (newline)=C2=A0 (display "old-funct: ") (display old-funct) (newline)=C2=A0 (display "new-funct: ") (display new-funct) (newline)
=
=C2=A0 new-funct)

i u= sed (define old-funct orig-funct) to backup the function instead of set! an= d the code can only called by a macro at top-level of a file and i can not = do this 'overloading' implementation with different scheme implemen= tation (Kawa,Racket,R6RS...) i had to store the overloading data in an hash= table in a global variable of a module that i probably export instead of r= edefining an existing function.
--000000000000c59dcb0621c333fc--