unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Roel Janssen <roel@gnu.org>
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: Guix-devel <guix-devel@gnu.org>
Subject: Re: [PATCH] gnu: graphviz: Enable Guile library.
Date: Tue, 10 May 2016 11:15:52 +0200	[thread overview]
Message-ID: <8737pq8e9j.fsf@gnu.org> (raw)
In-Reply-To: <20160510075324.110436e7@scratchpost.org>

Hello Danny,

Thank you for your elaborate response.  This makes it quite easy for me
to write the module file.  I added "write" and "rm" to the module, which
should make it complete.

What is the preferred way to include the module file to the package?
Should I create another package with this file alone, and use it as a
propagated input for graphviz?

Kind regards,
Roel Janssen


Danny Milosavljevic writes:

> Hi,
>
> On Mon, 09 May 2016 22:54:00 +0200
> Roel Janssen <roel@gnu.org> wrote:
>
>> it is automatically generated using SWIG.  I had to experiment a bit to
>> find out that the functions exposed in Guile did not have a namespace (gv.).
>
> You can add a prefix when importing, so the symbols of the module shouldn't have a prefix - the user would end up with two prefixes (or would have to cut the other prefix out and replace it or something).
>
>      (use-modules ((gdb) #:renamer (symbol-prefix-proc 'gdb:)))
>
> See also <http://www.swig.org/Doc2.0/Guile.html>.
>
>> There are functions called "rm" and "write" which are obviously already
>> used for other purposes in Scheme.  These functions will have to be
>> renamed or just left out of the Scheme module.  
>
> The user can specify which symbols to import (and also rename stuff there if needed) so I'd do nothing of the sort.
>
>      (use-modules ((ice-9 popen)
>                    #:select ((open-pipe . pipe-open) close-pipe)
>                    #:renamer (symbol-prefix-proc 'unixy:)))
>
> It's true that people still use the form
>
>    (use-modules (xxx))
>
> without specifying what the final imported symbols are, but that's something I consider bad practise in most cases (in any language - hey let's import random stuff into my namespace and have which module it gets each function from change on each package update. How about no?).
>
> For example, let's say you have two modules "a" and "b".
> Let module "a" contain "select".
> Let module "b" contain "write".
>
> Let's say you use it as
>
> (use-modules (a) (b))
>
> ; main program
> (write ...)
> (select ...)
>
> Then it will use b's write, a's select in your program, repectively. Say you release it and people use it. 
>
> Now let's say someone devious (not really, it can make sense to him) adds "select" to module "b". Suddenly your program will use b's select *even though you didn't change anything in it*. 
>
> Bad.
>
> A complete set to try this:
>
> $ export GUILE_LOAD_PATH=.
>
> ;;; a.scm
> (define-module (a) #:export (select))
> (define (select) (display "a.select") (newline))
>
> ;;; b.scm
> (define-module (b) #:export (write select))
> (define (write) (display "b.write") (newline))
> (define (select) (display "b.select") (newline))
>
> ;;; main.scm
> (use-modules (a) (b))
> (write)
> (select)
>
> Note that you do get warnings by guile
>
> WARNING: (guile-user): imported module (a) overrides core binding `select'
> WARNING: (guile-user): `select' imported from both (a) and (b)
> b.select
> WARNING: (guile-user): imported module (b) overrides core binding `write'
> b.write
>
> ... which is nice.

  reply	other threads:[~2016-05-10  9:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-09 10:17 [PATCH] gnu: graphviz: Enable Guile library Roel Janssen
2016-05-09 20:37 ` Ludovic Courtès
2016-05-09 20:54   ` Roel Janssen
2016-05-10  5:53     ` Danny Milosavljevic
2016-05-10  9:15       ` Roel Janssen [this message]
2016-05-10 13:08         ` Roel Janssen
2016-05-10 13:31         ` Ludovic Courtès
2016-05-10 14:07           ` Roel Janssen
2016-05-11 14:04             ` Ludovic Courtès
2016-05-11 14:48               ` Roel Janssen
2016-05-11 16:22                 ` Ludovic Courtès
2016-05-11 21:55                   ` Roel Janssen
2016-05-17 20:48                     ` Ludovic Courtès
2016-05-17 21:31                       ` Roel Janssen
2016-05-19 12:08                         ` Ludovic Courtès

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=8737pq8e9j.fsf@gnu.org \
    --to=roel@gnu.org \
    --cc=dannym@scratchpost.org \
    --cc=guix-devel@gnu.org \
    /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.
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).