The Hyper Programming Language

Namespaces

Introduction

A namespace is a named scope. Every source file uses a namespace (explicit or implicit) for its contents. Those contents are then members of the namespace.

Declaration

A namespace is declared in one line: namespace name. Such a declaration is placed on top of a source file, before all other things.

Explicit namespace

A namespace in Hyper is sort of a combination of packages in Java and namespaces in C++. A namespace is reflected in the directory structure of a source file. The declaration of a namespace will most often use nested namespaces. namespace Foo.Bar.Baz describes a namespace Foo nested in the (unnamed) root namespace and contains another namespace Bar, and Bar contains a namespace Baz. The sourcefile that is in this namespace will have to be named something like "someDirectory/Foo/Bar/Baz/someFileName.hyp".

All members of a namespace are public and accessible from outside. At this time only classes can be members of a namespace.

Implicit namespace

If no namespace is specified, then the contents of the source file are in an anonymous namespace. This is meant for simple programs that consist of just one source file. The file cannot be imported into another file, and it also cannot import other files itself; only standard library imports are allowed.

See also


Valid HTML 4.01 Strict Valid CSS!