GNU bug report logs - #76485
[PATCH] gexp: ‘with-parameters’ properly handles ‘%graft?’.

Previous Next

Package: guix-patches;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Sat, 22 Feb 2025 15:01:07 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: David Elsing <david.elsing <at> posteo.net>
To: Ludovic Courtès <ludo <at> gnu.org>, 76485 <at> debbugs.gnu.org
Subject: [bug#76485] [PATCH] gexp: ‘with-parameters’ properly handles ‘%graft?’.
Date: Tue, 25 Feb 2025 22:36:31 +0000
[Message part 1 (text/plain, inline)]
Hello,

Ludovic Courtès <ludo <at> gnu.org> writes:

> +         (mcall-with-parameters
> +             parameters
> +             (map (lambda (thunk) (thunk)) values)

Composing the monadic value here is a good idea I think.

> +  ;; XXX: Non-local exits can leave PARAMETERS set to VALUES.
> +  (mlet* %store-monad ((old-values
> +                        (return (map set-value parameters values)))
> +                       (result (thunk)))
> +    (mbegin %store-monad
> +      (return (map set-value parameters old-values)) ;restore old values
> +      (return result))))

However, I'm not convinced it is meaningful to set the parameters for a
general monad, e.g. for the identity monad or the list monad, there is
no way for the parameters to have an effect, only during the evaluation
of a function. Instead, I would suggest to only do this for the state
monad, as the parameters have an effect during the function application
of the monadic value to the state. The same applies to `mparameterized'
in (guix monads). Do you think that makes sense?

This allows for the use of `with-fluids*', keeping the parameterization
local. In the following message is a patch with the changes, which
(apart from the issue below) appears to work.

When testing the patch however, I noticed that `with-fluids*' does not
work with prompts and I get the following error:

--8<---------------cut here---------------start------------->8---
ERROR: Wrong type (expecting resumable continuation): #<vm-continuation 7f595e325690>
--8<---------------cut here---------------end--------------->8---

Attached is a minimal example, which works fine if `with-fluids*' is
removed. Is this behavior expected (I didn't see it in the
documentation) or is it a bug in Guile?

Cheers,
David


[test-prompt-fluids.scm (text/plain, inline)]
(define p (make-parameter 1))

(define cont
  (call-with-prompt 'foo
	(lambda ()
	  (with-fluids* (list (parameter-fluid p))
		(list 2)
		(lambda ()
		  (+ (abort-to-prompt 'foo) (p)))))
	(lambda (k)
	  k)))

(p 3)

(pk (cont 0))

This bug report was last modified 79 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.