develooper Front page | perl.perl6.internals | Postings from September 2005

HLL Namespace Design

Thread Next
Matt Diephouse
September 5, 2005 10:43
HLL Namespace Design
Message ID:
In order to help finish Parrot's HLL namespace support, I've compiled
a list of features and information that I believe is necessary to
support the target languages. I've done so after doing a survey of
these languages. I may have missed something or misunderstood
something: please check that this information matches what you know
about these languages.

It is my intent that this be merely a factual document. I want to
begin on the implementation details only after we have a clear

Naming Strategies and Storage

  Different languages store their variables and subroutines/methods in different
  ways and places. Parrot must support all of these and, if possible, allow


    1. Python: Variable and subroutine/method names overlap; you cannot have two
       items that share the same name.
    2. Ruby, Tcl: Variable and subroutine/method names do *not* overlap.
    3. Perl 5: Globs prevent overlap.
    4. Perl 6: Sigils prevent name collisions.

Default Namespaces

  Python:   __main__
  Ruby:     main
  Tcl:      ::
  Perl5:    main
  Perl6:    ::*Main

Namespace Capabilities

  - Importing
      Items must be imported from one namespace to another. Tcl requires that
      this be a snapshot - meaning that changes in the original namespace do
      not affect the imported items - while other languages use aliases.

      Items can be specified by tags (:all, :default), by patterns (c*), or by

  - Exporting
      Not all items can be exported; a list must be kept of which items can be. 
      These items can also be specified by tags, patterns, and names. Patterns
      are not expanded until the time of the import (which may occur more than 

  - Un-importing
      Tcl also allows you to un-import items using patterns. These can be
      specified using the namespace the command originally came from.

  - Querying Information
      It must be possible to get a list of both variables and subroutines,
      sometimes together and sometimes seperate.

      Tcl also allows you to get information about a namespace, such
as its name,
      its parent namespace, and its child namespaces.

  - Deleting
      It must be possible to delete:
        * Variables
        * Subroutines
        * Namespaces

Necessary Information

  - Child namespaces
  - Parent namespace
  - Current namespace
  - Subroutines (and their original namespaces)
  - Variables
  - Imported items
  - Exportable items
      * tags
      * names
      * patterns

Thanks for reading,

matt diephouse

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About