guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Brainstorming ideas for define-configuration


From: Liliana Marie Prikler
Subject: Re: Brainstorming ideas for define-configuration
Date: Fri, 10 Mar 2023 23:37:17 +0100
User-agent: Evolution 3.46.0

Am Freitag, dem 10.03.2023 um 20:15 +0000 schrieb jbranso@dismail.de:
> While I would agree that a guix service writer should avoid mutually
> exclusive fieldnames and instead prefer mutually exclusive records
> (and 95% of that time that will work), but may we examine it from a
> user's perspective? How does the service writer differentiate from
> a string title or string name?
> 
> Suppose that you want to respond to a king's rudeness. You can
> secretly insult him or obviously insult him:
> 
> ===Mutually exclusive records===, which are better from a
> maintainer's perspective, but perhaps cause the user to write more
> scheme:
> 
> "..your traitor brother. Maybe I’ll feed him to wolves after I’ve
> caught him. Did I tell you, I intend to challenge him to single
> combat?"
> 
> (insult-configuration
>   (response
>     (secret-insult-configuration
>       (secret-insult “I should like to see that, Your Grace.”))))
> 
> OR
> 
> "You can't insult me."
> 
> (insult-configuration
>   (response
>     (obvious-insult-configuration
>       (obvious-insult "We've had vicious kings and we've had idiot
> kings, but I don't know if we've ever been cursed with a vicious
> idiot for a king!"))))
> 
> ===Mutually exclusive fieldnames===
> 
> "I am the KING!"
> 
> (insult-configuration
>   (secret-insult "Any man who must say, 'I am the king' is no
> true king. I'll show you that after I've won your war.")))
> 
> OR
> 
> "You are Kingsguard!"
> 
> (insult-configuration
>   (obvious-insult "...F*ck the King."))))
> 
> These examples are pretty wonky I will admit, but I really like
> an option of having mutually exclusive fieldnames.  Having said all
> of this, I will agree that that mutually exclusive fieldnames are a
> bit like "goto" in C.  You really should never use them, unless you
> absolutely have to.
These insult configurations are a little crafted in that the insult-
configuration does not have enough fields to make the necessity of a
nested field obvious.  That is, you could just as easily write
  (insult-configuration
    (tone 'obvious)
    (insult "F*ck the King."))
and look at this record as a "single" value.

Note that neither serialization depends on the other.  For instance,
you can serialize this to XML as 
  <insult tone="obvious">F*ck the King.</insult>
where both fields just need to have their special characters escaped
and the serializer for insult-configuration stitch them together via
format strings.  Obviously, going through SXML would be better, but
it's possible.

Now, if you wanted to add more metadata, like the location at which
you've insulted the king and the time of day, none of which are of
interest for the content of your file, but perhaps of interest the
medium by which you choose to insult him, it would be better to keep
those concerns separate rather than merge them into a single record.

Cheers



reply via email to

[Prev in Thread] Current Thread [Next in Thread]