Package naming conventions

Pascal Bourguignon <[email protected]>
Newsgroups gmane.lisp.cclan.general
Organization InformatiMago.
Message-ID <[email protected]>
Nikodemus Siivola writes:
> This is essentially return to "vn-cclan package naming conventions and
> repository organization" thread from May.
> 
> What about:
> 
>  * Flat namespace. Packages are free to name themselves, but
>    moderation is applied so that canonical names aren't frivolously
>    grabbed.
> 
>    Eg. no "md5", unless it depends-on and provides a stable interface
>    to various implementation specific packages (sb-md5, etc), *and*
>    CCLAN is willing to make it the canonical CCLAN md5 interface.
> 
>    This obviously requires a process of some-sort, preferably
>    lightweight.

I  don't  like it.   It's  simple enough  to  have  the convention  of
prefixing the  package name by a  top-down domain name, as  is done in
java:

    COM.INFORMATIMAGO.COMMON-LISP.TREE       ;; can be loaded in any CL.
    COM.INFORMATIMAGO.COMMON-LISP.STRING
    COM.INFORMATIMAGO.CLISP.TREE             ;; use CLisp specifics.
    COM.INFORMATIMAGO.SBCL.TREE              ;; use SBCL specifics.

One can add/delete  nicknames when loading a package  if shorter names
are wanted. For  example, I have such provision  in my DECLARE-PACKAGE
macro:

 (DECLARE-PACKAGE COM.INFORMATIMAGO.COMMON-LISP.EXAMPLE
  (:NICKNAMES PJB-CL-EXAMPLE) ;; Should be avoided. Let the client assign nicks
  (:DOCUMENTATION "This is an example package declaration.")
  (:FROM COMMON-LISP :IMPORT :ALL)
  (:USE COM.INFORMATIMAGO.COMMON-LISP.TREE :AS TREE)
  (:EXPORT EXAMPLE-1 EXAMPLE-2))


I would reserver flat names for standardized interfaces.

For example, the flat name  COMMON-LISP correspond to a package with a
standardized list of exported symbols with well defined interface.

We  could define a  "TREE" or  a "GRAPH"  interface, and  have various
implementations:
    
    COM.INFORMATIMAGO.COMMON-LISP.TREE ;; my implementation of TREE.

    COM.INFORMATIMAGO.SBCL.TREE        ;; my implementation of TREE
                                       ;; optimized for, and dependent 
                                       ;; on SBCL.

    NET.SOURCEFORGE.CCLAN.TREE         ;; CCLAN implementation of TREE.

    ORG.CONS.CLISP.TREE                ;; A TREE implementation provided
                                       ;; with CLISP.


See also hierarchical packages from Franz Lisp:
http://www.franz.com/support/tech_corner/hierpackuser.lhtml


>  * Packages have category tags and a description. An CMUCL-specific
>    XML parser might belong to categories Text, XML, Parser, CMUCL.
> 
>    Packages that don't have any implementation tags are automatically
>    tagged "Portable".

The description  is named documentation. When defining  a package, you
can set a documention string:

    (DEFPACKAGE "COM.EXAMPLE.DOCUMENTED"
      (:DOCUMENTATION "Exemple de documentation."))

Unfortunately, I've  not found any  way to recover  this documentation
string, given  the name of the package.   Even (DESCRIBE (FIND-PACKAGE
NAME)) in  clisp does not display  it. The standard  doc-types for the
DOCUMENTATION     function      are:     COMPILER-MACRO,     FUNCTION,
METHOD-COMBINATION, SETF, STRUCTURE, T, TYPE, and VARIABLE.


One  of the problem  with DEFPACKAGE  is that  you're not  required to
declare the uses of external packages.  You declare importation of all
symbols  (with the  :USE clause),  or  of specific  symbols (with  the
:IMPORT clause).  It may be worthwhile to have a look at MODULA-2 (and
MODULA-3) that  have the finest  module (package) definition.   So, in
Common-Lisp,  you have  to scan  the whole  source to  learn  the used
packages.  I agree  that in some highly dynamic  programs, any package
could be used  at run-time.  But for 90% of the  packages, the list of
used packages is known even before compiling or loading them.

Hence in my DECLARE-PACKAGE, we have  a clause to specify that a given
package is used:

        (:USE COM.INFORMATIMAGO.COMMON-LISP.TREE)

we can add a nickname too:

        (:USE COM.INFORMATIMAGO.COMMON-LISP.TREE :AS TREE)

ad  we  have  a  clause   to  import  symbols  from  a  given  package
(automatically used then):

        (:FROM COM.INFORMATIMAGO.COMMON-LISP.TREE :IMPORT MAKE-TREE COPY-TREE)
or:
        (:FROM COM.INFORMATIMAGO.COMMON-LISP.TREE :IMPORT :ALL)


So now,  what is  a portable  package? It's a  package that  uses only
COMMON-LISP  and  other  packages  whose  use-closure  leads  only  to
COMMON-LISP.


 
>  * Provide a tool to search by categories, etc.

Why not search on the documentation strings rather?
 

> Cheers,
> 
>  -- Nikodemus

-- 
__Pascal_Bourguignon__                   http://www.informatimago.com/
----------------------------------------------------------------------
Do not adjust your mind, there is a fault in reality.


-------------------------------------------------------
This SF.net email is sponsored by Dice.com.
Did you know that Dice has over 25,000 tech jobs available today? From
careers in IT to Engineering to Tech Sales, Dice has tech jobs from the
best hiring companies. http://www.dice.com/index.epl?rel_code4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.