unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Making code compatible with different versions of Guile — #:declarative?
@ 2024-09-07 17:35 Dr. Arne Babenhauserheide
  2024-09-07 17:46 ` Making code compatible with different versions of Guile— #:declarative? Maxime Devos
  0 siblings, 1 reply; 3+ messages in thread
From: Dr. Arne Babenhauserheide @ 2024-09-07 17:35 UTC (permalink / raw)
  To: guile-devel

[-- Attachment #1: Type: text/plain, Size: 1326 bytes --]

Hi,

In the past year I often had to make code work on different versions on
Guile. Either because my laptop has a different distribution than my
Desktop (Trisquel vs. Guix) or because my server has yet another
distribution and may be on Debian stable (or oldstable).

The main problem for me was #:declarative? — a real showstopper.

To get the same behavior for mutating module bindings in Guile 3 and in
Guile 2 (for example for live development or for changing a function;
having a live REPL in Chickadee and building a game iteratively is a
great experience), I must mark the module as non-declarative:

(define-module (my-module)
  #:declarative? #f)

But #:declarative? is illegal in Guile 2.x, so I have to use different
code for 2.x and 3.x. And hitting that when I try to run a program on
another system is a really bad experience.

The problem is that #:declarative? is #true by default in Guile 3. But I
cannot change it if my code should work for Guile 2 *and* for Guile 3.

Would it be an alternative to explicitly mark all modules shipped with
Guile as #:declarative? #t but have user-code non-declarative by
default? Would that already yield most of the performance improvements?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Making code compatible with different versions of Guile— #:declarative?
  2024-09-07 17:35 Making code compatible with different versions of Guile — #:declarative? Dr. Arne Babenhauserheide
@ 2024-09-07 17:46 ` Maxime Devos
  2024-09-10 12:41   ` Damien Mattei
  0 siblings, 1 reply; 3+ messages in thread
From: Maxime Devos @ 2024-09-07 17:46 UTC (permalink / raw)
  To: Dr. Arne Babenhauserheide, guile-devel@gnu.org

[-- Attachment #1: Type: text/plain, Size: 974 bytes --]

>[...]
>The main problem for me was #:declarative? — a real showstopper.
>
> To get the same behavior for mutating module bindings in Guile 3 and in
Guile 2 (for example for live development or for changing a function;
having a live REPL in Chickadee and building a game iteratively is a
great experience), I must mark the module as non-declarative:

>(define-module (my-module)
>  #:declarative? #f)

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’t 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 ‘foo’ with an updated version is concerned), both in past, present and future.

(No comment on what the default _should_ be.)

Best regards,
Maxime Devos.

[-- Attachment #2: Type: text/html, Size: 3336 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Making code compatible with different versions of Guile— #:declarative?
  2024-09-07 17:46 ` Making code compatible with different versions of Guile— #:declarative? Maxime Devos
@ 2024-09-10 12:41   ` Damien Mattei
  0 siblings, 0 replies; 3+ messages in thread
From: Damien Mattei @ 2024-09-10 12:41 UTC (permalink / raw)
  To: Maxime Devos; +Cc: Dr. Arne Babenhauserheide, guile-devel@gnu.org

[-- Attachment #1: Type: text/plain, Size: 2350 bytes --]

On Sat, Sep 7, 2024 at 7:52 PM Maxime Devos <maximedevos@telenet.be> 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’t 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 ‘foo’ 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 = ") (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 = ") (display pred-list) (newline)
     ;;(display "new-funct : args = ") (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.

[-- Attachment #2: Type: text/html, Size: 4261 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-10 12:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-07 17:35 Making code compatible with different versions of Guile — #:declarative? Dr. Arne Babenhauserheide
2024-09-07 17:46 ` Making code compatible with different versions of Guile— #:declarative? Maxime Devos
2024-09-10 12:41   ` Damien Mattei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).