unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* reader macros for hidden packages
@ 2022-06-26  3:27 jgart
  2022-06-26  7:27 ` Maxime Devos
  2022-06-27  8:56 ` Ludovic Courtès
  0 siblings, 2 replies; 6+ messages in thread
From: jgart @ 2022-06-26  3:27 UTC (permalink / raw)
  To: Guix Devel


Hi Guixers,

Out of curiosity, is it possible to make reader macros like this with guile?

```
@hidden
(define-public python-httplib2
  (package
    (name "python-httplib2")
    (version "0.9.2")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "httplib2" version))
       (sha256
        (base32
         "126rsryvw9vhbf3qmsfw9lf4l4xm2srmgs439lgma4cpag4s3ay3"))))
    (build-system python-build-system)
    (home-page "https://github.com/jcgregorio/httplib2")
    (synopsis "Comprehensive HTTP client library")
    (description
     "A comprehensive HTTP client library supporting many features left out of
other HTTP libraries.")
    (license license:expat)))
```

The above would make the package hidden by using `hidden-package`.

I would imagine so... I'm just not sure where to begin looking to achieve something like that syntax.

See more discussion here:

https://todo.sr.ht/~whereiseveryone/guixrus/356

all best,

jgart


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: reader macros for hidden packages
  2022-06-26  3:27 reader macros for hidden packages jgart
@ 2022-06-26  7:27 ` Maxime Devos
  2022-06-26 14:43   ` jgart
  2022-06-27  8:56 ` Ludovic Courtès
  1 sibling, 1 reply; 6+ messages in thread
From: Maxime Devos @ 2022-06-26  7:27 UTC (permalink / raw)
  To: jgart, Guix Devel

[-- Attachment #1: Type: text/plain, Size: 1475 bytes --]

jgart schreef op za 25-06-2022 om 22:27 [-0500]:
> Out of curiosity, is it possible to make reader macros like this with guile?
> 
> ```
> @hidden
> (define-public python-httplib2
>   (package
>     (name "python-httplib2")
> [...]
> The above would make the package hidden by using `hidden-package`.

FWIW, read-hash-extend things aren't macros, though that can be worked
around with some cleverness, see (guix gexp) where #~(...) -> (gexp
...) by the read syntax, and 'gexp' is a macro.

Also, @hidden does not start with #, so you can't extend the read
syntax that wat with read-hash-extend. (I suppose  you could go #hidden
instead).

However, I cannot recommend this, for read syntax is global (not per
module, like the module system) and there can only be a single read
syntax per first character (so high chance for collisions).

It's also rather magical, and we already have the less magical but no
less concise 'hidden-package', why not:

(define-public python-httplib2
  (hidden-package
    (name "...")
    ...))

Or a new 'define-public-hidden':

(define-public-hidden python-httplib2
  (package
    (name "...")
    ...))

or move the relevant packages upstream?  Also, the module system has a
#:replace, which may be useful to put in the (guixrus packages ...)
modules such that in case a module imports both the guixrus and guix
module, the guixrus wins (not 100% sure if that would works).

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: reader macros for hidden packages
  2022-06-26  7:27 ` Maxime Devos
@ 2022-06-26 14:43   ` jgart
  2022-06-26 14:55     ` Maxime Devos
  0 siblings, 1 reply; 6+ messages in thread
From: jgart @ 2022-06-26 14:43 UTC (permalink / raw)
  To: Maxime Devos; +Cc: Guix Devel

On Sun, 26 Jun 2022 09:27:15 +0200 Maxime Devos <maximedevos@telenet.be> wrote:
> jgart schreef op za 25-06-2022 om 22:27 [-0500]:
> > Out of curiosity, is it possible to make reader macros like this with guile?
> > 
> > ```
> > @hidden
> > (define-public python-httplib2
> >   (package
> >     (name "python-httplib2")
> > [...]
> > The above would make the package hidden by using `hidden-package`.
> 
> FWIW, read-hash-extend things aren't macros, though that can be worked
> around with some cleverness, see (guix gexp) where #~(...) -> (gexp
> ...) by the read syntax, and 'gexp' is a macro.

I've tried reading that code. Looking to get back to it again soon. gexps
are still somewhat fuzzy for me. Atleast at the implementationn level.

> Also, @hidden does not start with #, 

I was inspired by this common lisp code using cl-syntax-annot:

https://github.com/fukamachi/ningle/blob/a9052827757c54a83c9648175c11530e79295513/context.lisp#L8

>so you can't extend the read
> syntax that wat with read-hash-extend. (I suppose  you could go #hidden
> instead).

Does read-hash-extend allow for more than a single character after the hash # symbol?

From reading the docs it looked like not... I'll spend some more repl time with it.


Just for the sake of hacking. I'm finding excuses to write guile that I
wouldn't normally write and to explore hacking on guix APIs to see what
I can mold them too.

Take this exploration with goops and guix for example:

https://github.com/drewc/druix/blob/ad1c15bd6e20375b83ce398416d0f16de0385ab5/druix/versions.scm#L33


> 
> Or a new 'define-public-hidden':
> 
> (define-public-hidden python-httplib2
>   (package
>     (name "...")
>     ...))

I like this idea. You'd implement that as a macro that inserts hidden-package for the user of define-public-hidden?

> or move the relevant packages upstream?  

Yup, that's the next step. Was just trying to find a way to suppress
warnings until I have time to upstream the relevant packages and to hack
me some guile for fun.

Also, the module system has a
> #:replace, which may be useful to put in the (guixrus packages ...)
> modules such that in case a module imports both the guixrus and guix
> module, the guixrus wins (not 100% sure if that would works).

Thanks for all the advice. It's much appreciated!

all best,

jgart


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: reader macros for hidden packages
  2022-06-26 14:43   ` jgart
@ 2022-06-26 14:55     ` Maxime Devos
  2022-06-26 20:08       ` jgart
  0 siblings, 1 reply; 6+ messages in thread
From: Maxime Devos @ 2022-06-26 14:55 UTC (permalink / raw)
  To: jgart; +Cc: Guix Devel

[-- Attachment #1: Type: text/plain, Size: 337 bytes --]

jgart schreef op zo 26-06-2022 om 09:43 [-0500]:
> > Or a new 'define-public-hidden':
> > 
> > (define-public-hidden python-httplib2
> >    (package
> >      (name "...")
> >      ...))
> 
> I like this idea. You'd implement that as a macro that inserts
> hidden-package for the user of define-public-hidden?

Yep.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: reader macros for hidden packages
  2022-06-26 14:55     ` Maxime Devos
@ 2022-06-26 20:08       ` jgart
  0 siblings, 0 replies; 6+ messages in thread
From: jgart @ 2022-06-26 20:08 UTC (permalink / raw)
  To: Maxime Devos; +Cc: Guix Devel

On Sun, 26 Jun 2022 16:55:26 +0200 Maxime Devos <maximedevos@telenet.be> wrote:
> jgart schreef op zo 26-06-2022 om 09:43 [-0500]:
> > > Or a new 'define-public-hidden':
> > > 
> > > (define-public-hidden python-httplib2
> > >    (package
> > >      (name "...")
> > >      ...))
> > 
> > I like this idea. You'd implement that as a macro that inserts
> > hidden-package for the user of define-public-hidden?
> 
> Yep.

Cool.

I'll try to write that macro and share it later if I get around to it.

I'm more comfortable currently with define-macro that with define-syntax-rule :(


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: reader macros for hidden packages
  2022-06-26  3:27 reader macros for hidden packages jgart
  2022-06-26  7:27 ` Maxime Devos
@ 2022-06-27  8:56 ` Ludovic Courtès
  1 sibling, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2022-06-27  8:56 UTC (permalink / raw)
  To: jgart; +Cc: Guix Devel

Hi,

jgart <jgart@dismail.de> skribis:

> Out of curiosity, is it possible to make reader macros like this with guile?
>
> ```
> @hidden
> (define-public python-httplib2

As Maxime notes, ‘read-hash-extend’ is the only reader extension
mechanism, and it only supports hash-prefixed extensions.

That said, I very much recommend against reader extensions because they
don’t compose (the extension is installed globally), they are not
namespaced, etc.  I find it OK in very narrow cases, such as gexps, but
I wouldn’t use them anywhere else.

The good thing is that we can often achieve concise syntax with sexps as
well, like:

  (define-public python-httplib2
    (hidden-package (package …)))

HTH!

Ludo’.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-27  8:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-26  3:27 reader macros for hidden packages jgart
2022-06-26  7:27 ` Maxime Devos
2022-06-26 14:43   ` jgart
2022-06-26 14:55     ` Maxime Devos
2022-06-26 20:08       ` jgart
2022-06-27  8:56 ` Ludovic Courtès

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).