Name Prefixes

cbbrowne@acm.org cbbrowne@acm.org
Tue, 01 Oct 2002 10:28:47 -0400


On 01 Oct 2002 10:15:31 EDT, the world broke into rejoicing as
Derek Atkins <warlord@MIT.EDU>  said:
> Han-Wen Nienhuys <hanwen@cs.uu.nl> writes:
> 
> > warlord@MIT.EDU writes:
> > > 
> > >         (gnc:module-load "<this-module>" 0)
> > > 
> > 
> > just by-the-by: is this an official convention, I mean
> > 
> >      prefix:function-name
> > 
> > (just wondering whether I should follow that convention as well.)

> It is an official GnuCash convention..  I don't know if it is a guile
> convention in general.

If GnuCash was using Common Lisp as the extension language, it would be
entirely appropriate for modules to create their own "packages" which
generate distinct namespaces.

And the colon is used expressly as a separator between the "package
name" and the actual object names.

Thus, if we were in namespace GNC, by virtue of
(in-package 'GNC) or (progn (require 'GNC) (import 'GNC))

we'd be able to just type in

  (module-load "this module" 0)

If we took off the (import 'GNC) that adds the GNC names into the
current namespace, we'd have to write
  (gnc:module-load "this module" 0)
which, by no coincidence, is what we started with in the Guile
discussion.

If we didn't do any kind of (import), then it would be necessary to
"punch through" the namespace barrier via:
  (gnc::module-load "this module" 0)
as the double colon indicates "I want to access that object even though
I'm really not supposed to access it."

If you're adding your own extension module, it would probably make a lot
of sense to use your own 'namespace.'

For instance, I'd think it pretty sensible for an OFX package extension
to have functions with names like ofx:read-transaction and
ofx:validate-account.

The proper "rule of thumb" is probably that modules that aren't
"officially" part of GnuCash should not have "gnc:" prefixes.
--
(concatenate 'string "cbbrowne" "@cbbrowne.com")
http://www3.sympatico.ca/cbbrowne/x.html
As of next Monday, TRIX will be flushed in favor of VISI-CALC.
Please update your programs.