From the little bit of SICP that I've done, I recall watching the
lectures where
they put a mage hat on and talk about the power of names. One could
perhaps say
the most powerful tool in a programming language is the ability to give
something a name and then refer to those names.
In guix/guile, record types are list of names given to some data.
For example:
(define foo
(package
(name "bar")
(version "1.0")
...)
Here we the names foo, name, version, that refer to things of interest.
We can
call foo easily enough to get the record, but we cannot refer to name or
version so easily. We instead have to use accessors like (package-name
foo),
which requires us to write foo each time explicitly and have repeat package-
for each accessor.
In the guix codebase, on many occasions there appear things like this:
(match-lambda
(($ <agetty-configuration> agetty tty term baud-rate auto-login
login-program login-pause? eight-bits? no-reset? remote?
flow-control?
host no-issue? init-string no-clear? local-line extract-baud?
skip-login? no-newline? login-options chroot hangup? keep-baud?
timeout
detect-case? wait-cr? no-hints? no-hostname? long-hostname?
erase-characters kill-characters chdir delay nice extra-options)
(list
....
Here we have given some names to things, abandoned those names, and once
again
gone to the trouble of naming them again, in order, just for one local
environment. We'd have to do it again to make use of it elsewhere, and I
assume
they would have to change if the record type it self needed to be updated.
Wouldn't be nice if we could just step inside a record type whenever we
pleased?
The above would be like this perhaps:
(let-from-record-type <agetty-configuration>
(list ...))
"let-from-record-type" i just made up since i dont know what it should be
called. Anyhow, it seems like we're stepping back a few centuries in
computer
science by needing to jump through these hoops.
The list of symbols can be retreived with (record-type-fields
<agetty-configuration>), but I can't think of how one would write the above
syntax.
Opinions?