* Best practices for processing s-expressions representing configurations/DSLs
@ 2018-12-17 19:10 Stephen Scheck
2018-12-17 21:35 ` John Cowan
2018-12-18 16:50 ` Ludovic Courtès
0 siblings, 2 replies; 3+ messages in thread
From: Stephen Scheck @ 2018-12-17 19:10 UTC (permalink / raw)
To: guile-user
Hello,
I'm very new to Guile/Scheme/Lisp programming (but love the concise,
minimalist syntax!), so please bear with what may be some obvious answers.
When representing application configurations or DSLs as s-expressions, what
are common or best strategies for processing them? For example, here's an
excerpt I found of the Guix package definition DSL to study as a prototype:
(package
(name "hello")
(version "2.10")
(build-system gnu-build-system)
(arguments '(#:configure-flags '("--enable-silent-rules")))
(inputs `(("gawk" ,gawk)))
(synopsis "Hello, GNU world: An example GNU package")
(description "Guess what GNU Hello prints!")
(home-page "http://www.gnu.org/software/hello/")
(license gpl3+))
Would this just be executed directly within the equivalent of a regular
Guile REPL (with the Guix extensions loaded, of course) ? Is each "key"
(e.g. "name" or "build-system") just a function call? Or would it be better
to slurp the whole s-expr in as a quoted, unevaluated structure, and
iterate through its various sub-components, using conditionals to match the
various keys and processing as necessary? I.e. would it be more typical to
view the structure as just data, an arbitrarily nested list structure, with
separate code to process it, or as code itself? Oh homoiconicity, it is a
slippery notion!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Best practices for processing s-expressions representing configurations/DSLs
2018-12-17 19:10 Best practices for processing s-expressions representing configurations/DSLs Stephen Scheck
@ 2018-12-17 21:35 ` John Cowan
2018-12-18 16:50 ` Ludovic Courtès
1 sibling, 0 replies; 3+ messages in thread
From: John Cowan @ 2018-12-17 21:35 UTC (permalink / raw)
To: Stephen Scheck; +Cc: guile-user
Definitely you should view it as data. Think more than twice (indeed, more
than 200 times) before you evaluate s-expressions coming from outside.
"Eval is spelled E-V-I-L".
On Mon, Dec 17, 2018 at 4:03 PM Stephen Scheck <singularsyntax@gmail.com>
wrote:
> Hello,
>
> I'm very new to Guile/Scheme/Lisp programming (but love the concise,
> minimalist syntax!), so please bear with what may be some obvious answers.
>
> When representing application configurations or DSLs as s-expressions, what
> are common or best strategies for processing them? For example, here's an
> excerpt I found of the Guix package definition DSL to study as a prototype:
>
> (package
> (name "hello")
> (version "2.10")
> (build-system gnu-build-system)
> (arguments '(#:configure-flags '("--enable-silent-rules")))
> (inputs `(("gawk" ,gawk)))
> (synopsis "Hello, GNU world: An example GNU package")
> (description "Guess what GNU Hello prints!")
> (home-page "http://www.gnu.org/software/hello/")
> (license gpl3+))
>
> Would this just be executed directly within the equivalent of a regular
> Guile REPL (with the Guix extensions loaded, of course) ? Is each "key"
> (e.g. "name" or "build-system") just a function call? Or would it be better
> to slurp the whole s-expr in as a quoted, unevaluated structure, and
> iterate through its various sub-components, using conditionals to match the
> various keys and processing as necessary? I.e. would it be more typical to
> view the structure as just data, an arbitrarily nested list structure, with
> separate code to process it, or as code itself? Oh homoiconicity, it is a
> slippery notion!
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Best practices for processing s-expressions representing configurations/DSLs
2018-12-17 19:10 Best practices for processing s-expressions representing configurations/DSLs Stephen Scheck
2018-12-17 21:35 ` John Cowan
@ 2018-12-18 16:50 ` Ludovic Courtès
1 sibling, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2018-12-18 16:50 UTC (permalink / raw)
To: guile-user
Hello,
Stephen Scheck <singularsyntax@gmail.com> skribis:
> When representing application configurations or DSLs as s-expressions, what
> are common or best strategies for processing them? For example, here's an
> excerpt I found of the Guix package definition DSL to study as a prototype:
>
> (package
> (name "hello")
> (version "2.10")
> (build-system gnu-build-system)
> (arguments '(#:configure-flags '("--enable-silent-rules")))
> (inputs `(("gawk" ,gawk)))
> (synopsis "Hello, GNU world: An example GNU package")
> (description "Guess what GNU Hello prints!")
> (home-page "http://www.gnu.org/software/hello/")
> (license gpl3+))
>
> Would this just be executed directly within the equivalent of a regular
> Guile REPL (with the Guix extensions loaded, of course) ? Is each "key"
> (e.g. "name" or "build-system") just a function call?
The expression above expands to a (make-struct <package> …) call, which
instantiates a record (also called a structure in some languages.)
The article at <https://arxiv.org/pdf/1305.4584v1.pdf> explains it in
more detail.
HTH!
Ludo’.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-12-18 16:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-17 19:10 Best practices for processing s-expressions representing configurations/DSLs Stephen Scheck
2018-12-17 21:35 ` John Cowan
2018-12-18 16:50 ` Ludovic Courtès
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).