# Command: using

NEST HelpDesk | Command Index | NEST Quick Reference

Name:

    using - Make symbols of a namespace or dictionary available in the current scope.

Synopsis:

      /namespace	 using ...your.code... endusing ->	-
      <> using ...your.code... endusing ->	-

Examples:

      % the following makes the routines of the unittest library available to the current scope:
      (unittest) run
      /unittest using
      ..your code..
      endusing

      % the following makes the models in modeldict available to the current scope:
      modeldict using
      ..your code..
      endusing

      % alternatively, you can also use the literal name:
      /modeldict using
      ..your code..
      endusing

Description:

      The 'using' statement provides read access to a namespace or
      dictionary, without changing the current scope for new symbol
      definitions.

      The 'using' statement must be closed by 'endusing'.

      **********************************************************************
      * IMPORTANT:	 *
      * The 'using' statement puts the specified namespace	 *
      * or dictionary in the second position of the dictionary stack. This *
      * means that LOCAL SYMBOLS WILL SHADOW SYMBOLS OF THE SAME NAME FROM *
      * THE SPECIFIED NAMESPACE OR DICTIONARY. This makes the 'using'	 *
      * statement unsafe in all situations where you do not have explicit  *
      * control of the current dictionary. YOU MAY END UP CALLING A	 *
      * FOREIGN SYMBOL.	 *
      * There are two ways to avoid this problem:	 *
      * (a) use 'namespace' or 'call', which provide read/write access to  *
      *	 the namespace or dictionary and don't have the shadowing *
      *	 problem.	 *
      * (b) put an empty dictionary on the dictionary stack at the	 *
      *	 beginning of your routine, providing a local symbol	 *
      *	 scope for your routine. The 'SLIFunctionWrapper'	 *
      *	 command does this for you automatically.	 *
      **********************************************************************

Parameters:

      /name		- name of the the namespace to use
      <>	- dictionary to use

Diagnostics:

      If the name is not known,  UndefinedNameError is raised.
      If the name is not bound to a dictionary, TypeMismatchError is raised.

Remarks:

      Please note that 'using'/'endusing' is implemented by the opening and
      closing of dictionaries. Code between 'using' and 'endusing' should
      hence have completely matched 'begin' and 'end' statements, or special
      care must be taken when using non-matched 'begin'/'end' constructs
      inside a 'using' context.

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:

    6-aug-2003

SeeAlso:

- endusing
- namespace
- call

Source:

    /opt/conda/conda-bld/nest_1512421404550/work/nest-2.12.0/lib/sli/library.sli

NEST HelpDesk | Command Index | NEST Quick Reference

© 2004 The NEST Initiative