From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vincent Legoll Subject: Re: Newbie packagers Date: Thu, 21 Jul 2016 19:13:32 +0200 Message-ID: References: <87poq7dm44.fsf@elephly.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQHXT-0000d0-55 for help-guix@gnu.org; Thu, 21 Jul 2016 13:13:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQHXR-0001Ai-PB for help-guix@gnu.org; Thu, 21 Jul 2016 13:13:35 -0400 Received: from mail-qt0-x22b.google.com ([2607:f8b0:400d:c0d::22b]:34761) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQHXR-0001Ad-Jq for help-guix@gnu.org; Thu, 21 Jul 2016 13:13:33 -0400 Received: by mail-qt0-x22b.google.com with SMTP id u25so47684511qtb.1 for ; Thu, 21 Jul 2016 10:13:33 -0700 (PDT) In-Reply-To: <87poq7dm44.fsf@elephly.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: Ricardo Wurmus Cc: help-guix@gnu.org Hello, Thanks a lot, this is really helpful ! On Thu, Jul 21, 2016 at 5:52 PM, Ricardo Wurmus 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=E2=80=99t get evaluated any further. > This is pretty much the same as: > > `(+ 1 2 3) > > But with the backtick (called =E2=80=9Cquasiquote=E2=80=9D) you are permi= tted to > temporarily switch from =E2=80=9Cdata mode=E2=80=9D to =E2=80=9Ccode mode= =E2=80=9D. That=E2=80=99s what the > comma (=E2=80=9Cunquote=E2=80=9D) 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=E2=80=99s nice about this is that we can use the same syntax for cod= e 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 =E2=80=9Cstaging=E2=80=9D. When you look at a typical pa= ckage > expression you see that the value of the =E2=80=9Carguments=E2=80=9D fiel= d 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 =E2=80=94 it actually contain= s the > very values themselves! > > =E2=80=9C,@=E2=80=9D 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, espec= ially with that quasiquote thing... > (let ((moo '(1 2 3))) > `(foo bar ,@moo meh)) > > This binds the list '(1 2 3) to the name =E2=80=9Cmoo=E2=80=9D and then s= plices it into > another list. This results in > > '(foo bar 1 2 3 meh) > > Without the =E2=80=9C@=E2=80=9D and just a regular unquote comma it would= be a nested > list: > > (let ((moo '(1 2 3))) > `(foo bar ,moo meh)) > > =3D> '(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=E2=80=99s no operator. It=E2=80=99s part of the name. We use the p= ercent as a > prefix for variables that are =E2=80=9Cspecial=E2=80=9D, e.g. global vari= ables 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=E2=80=99s 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 =E2=80=9C#:use-module=E2=80=9D only in module definitions. > =E2=80=9C(use-modules =E2=80=A6)=E2=80=9D 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 th= e .texi part ! --=20 Vincent Legoll