# Command: namespace

NEST HelpDesk | Command Index | NEST Quick Reference

Name:

    namespace - Open a namespace

Synopsis:

      /name namespace ...your.code... end ->	-

Examples:

      /myspace namespace % this opens namespace "myspace"
      /var 23 def	 % this creates the variable "myspace::var"
      /func {(This is stupid.) =} def % this creates the function "myspace::func"
      end	 % this closes the namespace "myspace"

      /myspace namespace % this re-opens the namespace "myspace"
      who	 % this shows the variables defined in the namespace
      end	 % this closes the namespace "myspace"

      myspace /func call % this calls "myspace::func"

Description:

      "namespace" provides to SLI the concept of namespaces,
      as known from C++.

      The command changes the current scope to the namespace of the given
      name, i.e.,
     	- all following symbol definitions go to this namespace
     	- all symbols that were previously defined in this namespace become
      known
      The namespace must be closed by an "end" statement.

      The symbols defined in a namespace persist across closing and
      re-opening of the namespace. Namespaces can be nested.

      For alternative ways of accessing a namespace,
      see "using" and "call".

Parameters:

      /name	- the namespace to open

Diagnostics:

      If the named object is not a dictionary, TypeMismatchError is raised.

Remarks:

      Currently, namespaces are implemented as
      dictionaries. Namespaces may become more tightly
      integrated with the SLI interpreter in future.
      The idea is to define a set of symbols not in the global user
      dictionary, but in a separate dictionary that has the name of the
      namespace. Thus, symbols in different namespaces can have
      identical names, and are effectively disambiguated by the current
      dictionary context.
      Note that the namespace dictionary is looked up and created in the
      current scope. This is to allow for nested namespaces.

Availability:

    SLI2.0

References:

      [1] Ruediger Kupper, SLI library management,
      HRI-EU Report 06/05, Honda Research Institute Europe GmbH, 2006.

Author:

      Ruediger Kupper

FirstVersion:

      21-jul-2003

SeeAlso:

- call
- using
- endusing

Source:

    /opt/conda/conda-bld/nest_1512418773968/work/nest-2.14.0/lib/sli/library.sli

NEST HelpDesk | Command Index | NEST Quick Reference

© 2004 The NEST Initiative