User Tools

Site Tools


namespace_declare_a_scope_.htm
Navigation:  Clarion.Net (Clarion#) > Clarion# Language Extensions > Compiler Directives >====== NAMESPACE (declare a scope) ====== Previous pageReturn to chapter overviewNext page

NewCNet.jpg

NAMESPACE identifier [,GLOBALCLASS (name)]

blk2blue.jpg

NAMESPACE declare a program element's scope
identifier A string that identifies the NAMESPACE. Quotes around the string name are not required. Parenthesis are optional.
GLOBALCLASS Set explicit name of global class
name A string constant that identifies the name of the global class.

The NAMESPACE compiler directive is used to declare a scope within the .NET framework. This scope lets you organize code and gives you a way to create globally-unique types. Namespaces are used both as an “internal” organization system for a program, and as an “external” organization system ' a way of presenting program elements that are exposed to other programs.

NoteBox.jpg

You cannot name an object (FILEs, CLASSes, QUEUEs, GROUPs, data types, etc.) that uses the same name as the containing identifier. The compiler will post a CLA0185 error (Identifier is already defined).

NAMESPACE can be placed only in the global data section after the PROGRAM statement in the program source files, or in the local static data section after a MEMBER statement in the member source files.

You can use namespace directive in included files (see INCLUDE directive). In this case the directive must be first statement in the included file.

If a MEMBER module doesn't contain a NAMESPACE directive, then the PROGRAM module's namespace is used for the MEMBER module.

All global declarations of a namespace are translated as members of special global class. By default the name of the global class is Global<;name of source file>. You can set the name of global class explicitly with GLOBALCLASS attribute. The use of GLOBALCLASS is optional, and is seldom used or required.

Example:

PROGRAM

NAMESPACE(Threads),GLOBALCLASS('Gthread')

USING(System)

USING(System.Drawing)

USING(System.Windows.Forms)

See Also: USING (reference a namespace)

namespace_declare_a_scope_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1