From: Taylan Kammer <taylan.kammer@gmail.com>
To: raid5atemyhomework <raid5atemyhomework@protonmail.com>,
"guix-devel@gnu.org" <guix-devel@gnu.org>
Subject: Re: A new paradigm for modifying operating system declarations
Date: Mon, 4 Jan 2021 21:21:20 +0100 [thread overview]
Message-ID: <87b59430-b53e-47ec-32d5-abbd3be42ce7@gmail.com> (raw)
In-Reply-To: <ewUh5vMEW_m5K1m9xYSvxi0_o92wTXSO8pAoyBec8LDT45bZmrNXc6hPH4_3ZXWTyqe91NDltmJgH5mEDbpsu-A6Ar0vpDqky8F4kCrhlcI=@protonmail.com>
On 04.01.2021 16:38, raid5atemyhomework wrote:
> Hi guix-developers,
>
> I'd like to propose an idea for constructing `<operating-system>` objects.
>
> [... snip ...]
>
> What are your opinions? Blech? Yummy? Is it worth exploring this paradigm for adding particularly complex features to an operating system definition?
Hi,
Interesting idea.
First, let me point out a more conventional alternative to what your
'decorate' macro does:
(define (compose proc . rest)
"Functional composition; e.g. ((compose x y) a) = (x (y a))."
(if (null? rest)
proc
(let ((rest-proc (apply compose rest)))
(lambda x
(let-values ((x (apply rest-proc x)))
(apply proc x))))))
This allows for something like:
((compose install-foo install-bar install-zfs)
(operating-system ...))
Or perhaps cleaner:
(define my-os-modifier (compose install-foo install-bar install-zfs))
(my-os-modifier
(operating-system ...))
If you need custom modifications within, you can do:
(define my-os-modifier
(compose install-foo
(lambda (os) ...)
install-bar))
It's more verbose, but doesn't "break" standard Scheme syntax as much.
Function composition is conceptually pretty easy and probably more
well-known than "decorators" (which I had never heard of, personally).
Fewer macros means the reader needs to keep fewer special rules in mind.
---
Secondly, I wonder if passing an OS declaration through various
procedures that modify it is really the best approach in the first place.
For build phases, we have the 'modify-phases' syntax. For services,
there is 'modify-services'. Maybe there should be a 'modify-os' kind of
syntax. (In other words, if we're going to invent new syntax, why not
go all-out and create the most convenient syntax for the use-case.)
Just my thoughts.
- Taylan
next prev parent reply other threads:[~2021-01-04 20:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-04 15:38 A new paradigm for modifying operating system declarations raid5atemyhomework
2021-01-04 20:21 ` Taylan Kammer [this message]
2021-01-05 0:32 ` raid5atemyhomework
2021-01-05 6:12 ` Carlo Zancanaro
2021-01-05 10:01 ` raid5atemyhomework
2021-01-04 23:26 ` Jan Wielkiewicz
2021-01-05 0:46 ` raid5atemyhomework
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87b59430-b53e-47ec-32d5-abbd3be42ce7@gmail.com \
--to=taylan.kammer@gmail.com \
--cc=guix-devel@gnu.org \
--cc=raid5atemyhomework@protonmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
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).