From mboxrd@z Thu Jan 1 00:00:00 1970 From: Danny Milosavljevic Subject: Re: [PATCH] gnu: graphviz: Enable Guile library. Date: Tue, 10 May 2016 07:53:24 +0200 Message-ID: <20160510075324.110436e7@scratchpost.org> References: <87shxrpmbj.fsf@gnu.org> <87h9e7nf2i.fsf@gnu.org> <87a8jzc5qv.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b00bu-0000Kk-VJ for guix-devel@gnu.org; Tue, 10 May 2016 01:53:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b00bq-0001k2-LB for guix-devel@gnu.org; Tue, 10 May 2016 01:53:33 -0400 In-Reply-To: <87a8jzc5qv.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Roel Janssen Cc: Guix-devel Hi, On Mon, 09 May 2016 22:54:00 +0200 Roel Janssen 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 . > 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.