[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using srfi-189 in (gnu services configuration)
From: |
Attila Lendvai |
Subject: |
Re: using srfi-189 in (gnu services configuration) |
Date: |
Wed, 30 Mar 2022 12:32:06 +0000 |
> > - the current code uses the symbol 'DISABLED
>
> It's a bit of a distraction to the discusses issue, but in Guile
> Scheme, symbols are case-sensitive, so (not (eq? 'disabled 'DISABLED)).
to clarify: i'm using uppercase here only to discriminate scheme
symbols from a free-flowing english text. it's common practice in the
CL world, but i've also seen it in the Guix docstrings.
> This does not appear to be true, at least for (srfi srfi-9) records:
>
> the following code can put unspecified in Guile records without any
> errors:
>
> (use-modules (srfi srfi-9))
> (define-record-type <foobar>
> (make-foobar foo) foo? (foo foobar-foo))
> (pk 'foobar (make-foobar unspecified))
> ;;; (foobar #<<foobar> foo: #<unspecified>>)
my apologies for stating something with confidence that is not true!
i have vivid memory of having tried to use *unspecified*, and getting
errors from record accessors, but i cannot reproduce it now. maybe i
did something with UNDEFINED?, but i don't even see now how to get
hold of that value.
anyway, i'll try to patch up (gnu services configuration) to use
*unspecified* instead of 'DISABLED, and i'll report back with the end
result it it's worthy of that.
> Anyway, even if unspecified causes problems, this can be resolved by
> introducing a new constant like unspecified or the symbol 'disabled',
> but without the potential confusion with a symbol. E.g.:
>
> (define-values (unset-configuration-value unset-configuration-value?)
> (let ()
> (define-record-type <unset-configuration-value>
> (make-unset-configuration-value) unset-configuration-value?
> unset-configuration-value?)
> (values (make-unset-configuration-value)
> unset-configuration-value?)))
it's not really relevant now, but this is pretty much what srfi-189
does, but as a documented standard.
> srfi-189 is also an option, but it seems to me that Haskell-style
> Maybe/Just/None that would require lots of wrapping and unwrapping
> which seems a bit tedious to me -- doable and definitely an option, but
> potentially tedious.
i'm afraid about that, too, but i cannot say before i start
implementing it.
and i think the config code will be equally littered with (if
(unspecified? ...) ...) forms, as opposed to (maybe-ref ...) forms
when using srfi-189.
> Additionally, for your Swarm example, would something like the
> following work:
this is an excellent idea! (namely, to capture the settings of various
swarms into instances, and then predefine the two well-known swarms)
i'll implement this first, and only move on to the config stuff
afterwards.
thanks again Maxime,
--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“He alone is great and happy who fills his own station of independence, and has
neither to command nor to obey.”
— Johann Wolfgang von Goethe (1749–1832), 'With the Iron Hand' (1773),
Act I