unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Vincent Legoll <vincent.legoll@gmail.com>
To: Ricardo Wurmus <rekado@elephly.net>
Cc: help-guix@gnu.org
Subject: Re: Newbie packagers
Date: Thu, 21 Jul 2016 19:13:32 +0200	[thread overview]
Message-ID: <CAEwRq=o1V+9E5NaYZ-3ZsewVj3ph6f+e+6EamYeVErdetk0TQQ@mail.gmail.com> (raw)
In-Reply-To: <87poq7dm44.fsf@elephly.net>

Hello,

Thanks a lot, this is really helpful !

On Thu, Jul 21, 2016 at 5:52 PM, Ricardo Wurmus <rekado@elephly.net> wrote:
>> - the comma operator
>> - the backquote operator
>> - the quote operator
>> - the arobase operator (is it for list unpacking ?)
>
> These are all about list quoting.
> This is code:
>
>     (+ 1 2 3)
>
> It evaluates to 6.
>
> This is quoted code (aka data):
>
>     '(+ 1 2 3)

Those I knew/remembered from my CS student days, it's the other
2 I didn't grok...

> It doesn’t get evaluated any further.
> This is pretty much the same as:
>
>     `(+ 1 2 3)
>
> But with the backtick (called “quasiquote”) you are permitted to
> temporarily switch from “data mode” to “code mode”.  That’s what the
> comma (“unquote”) does:
>
>     `(+ 1 2 3 4 ,(+ 3 2) 6)
>     ^           ^
>     data mode   code mode
>
> The result is the same as
>
>     '(+ 1 2 3 4 5 6)
>
> What’s nice about this is that we can use the same syntax for code that
> is to be evaluated right now and for code that we want to pass somewhere
> else as inert data which will be evaluated at a later point.
>
> This allows for “staging”.  When you look at a typical package
> expression you see that the value of the “arguments” field is quoted.
> It is not evaluated right away but in a second stage.
>
> The value of the inputs field is also quoted.  You see that we unquote
> the values of package variables there.  Package expressions in Guix are
> just Scheme values.  The inputs field does not merely hold a list of
> symbols that somehow represent the packages — it actually contains the
> very values themselves!
>
> “,@” is for splicing lists:

That one I guessed, but wasn't sure because of the still unknown comma...
Python has something similar, but it does not look as useful as this, especially
with that quasiquote thing...

>     (let ((moo '(1 2 3)))
>       `(foo bar ,@moo meh))
>
> This binds the list '(1 2 3) to the name “moo” and then splices it into
> another list.  This results in
>
>     '(foo bar 1 2 3 meh)
>
> Without the “@” and just a regular unquote comma it would be a nested
> list:
>
>     (let ((moo '(1 2 3)))
>       `(foo bar ,moo meh))
>
> =>  '(foo bar (1 2 3) meh)
>
> Quoting and unquoting is a very useful feature.  I hope my explanations
> above are easy to understand.

Perfect, clear, that was just what I needed. I will not immediately
be used to those concepts, but I understand what they do, that's
sufficient to read code...

The big problem with the abbreviated forms is that they're not easily
googlable, if I knew their long names, I could've found them in online
doc...

>> - the percent operator
>
> That’s no operator.  It’s part of the name.  We use the percent as a
> prefix for variables that are “special”, e.g. global variables or

OK, only a naming convention then ?

> values that appear without having to be explicitly let-bound.

That could use a little pointer, because the idea is strange, you
mean implicit variables (bindings), kind of like perl's $_ ?

>> - the #: operator
>
> These are called keyword arguments.  They are no operators either.
> Using keyword arguments allows you to specify arguments by name, not in
> some fixed order.

That I also guessed (I'm coming from **kwargs-land...), but they also look
more powerful...

>> - the different module import things (#:use-module vs (use-modules) vs ...)
>
> That’s probably explained in the Guile reference manual.

Yes, I read a bit about that in there, but the following is what I
wanted to know :

> We use “#:use-module” only in module definitions.
>  “(use-modules …)” can be used anywhere else.

> Yeah, I agree.  There should be a quick crash course.  I spent half the
> day yesterday to introduce all these things to a colleague who will
> create a few Guix packages in the future.  It would be cool to have this
> as part of the manual.

Thanks a lot, this is just what's missing, and looks like Ludo's covered the
.texi part !

-- 
Vincent Legoll

  reply	other threads:[~2016-07-21 17:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-21 13:21 Newbie packagers Vincent Legoll
2016-07-21 15:52 ` Ricardo Wurmus
2016-07-21 17:13   ` Vincent Legoll [this message]
2016-07-22  8:30     ` Chris Marusich
2016-07-23 10:21   ` Andreas Enge
2016-07-23 10:36     ` Vincent Legoll
2016-07-21 15:54 ` Ludovic Courtès
2016-07-21 17:19   ` Vincent Legoll
2016-07-21 18:04     ` Vincent Legoll
2016-07-22  7:13       ` Vincent Legoll
2016-07-22 12:23         ` Ludovic Courtès
2016-07-22 12:43           ` Vincent Legoll
2016-07-22 12:41       ` Ludovic Courtès
2016-07-22 12:46         ` Vincent Legoll
2016-07-22 14:41           ` Ludovic Courtès
2016-07-22 20:01             ` Vincent Legoll

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='CAEwRq=o1V+9E5NaYZ-3ZsewVj3ph6f+e+6EamYeVErdetk0TQQ@mail.gmail.com' \
    --to=vincent.legoll@gmail.com \
    --cc=help-guix@gnu.org \
    --cc=rekado@elephly.net \
    /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.
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).