The Hyper Programming Language

Source files

General

A source file is a text file, containing source code that is written in Hyper. For very small programs, a source file contains the source code of the entire program; however most of the time a program is split up in multiple source files. The content of a source file is subject to the syntactic and semantic rules of the Hyper language. If you want to put non-source code text in the file, you need to mark that as comments.

Differences with other languages

Hyper uses a system similar to that of Java. Unlike in C++, declarations and definitions are not separated in different files; Hyper does not use header files. Another difference compared to C++ is that Hyper has no preprocessor. And while C++ and Java are free-form languages, Hyper is not (or at least not completely).

Filename

A source file must use the extension ".hyp" or ".hyper". The path of a sourcefile must correspond to the namespace that the file uses, unless the file doesn't declare its namespace.

Contents of a source file

Any source file contains these things, and only in this order:

A source file can have only one begin directive. This directive (if you need one) and the imports must come before the namespace. A source file needs a 'begin' directive to be able to use the file as a program's entry point.

Though the namespace declaration is optional, most programs will have to use it. Omitting the declaration implies you put the contents of the file into an anonymous (unnamed) namespace, so the contents of the file are not accessible from outside. This means you can only omit the namespace declaration in files that contain the main entry point of an executable and no code that needs to be used from within other source files.

General syntax issues

A newline is significant in Hyper. If you want to spread something like a statement over more than one line, you will have to put an underscore (and a space) before the lines that are a continuation of the previous line:

static procedure p()
	system.Out.line("This is a very very very very very very very very very very "
		_ + "looooooooooooooooooooooooooooooooong line!")
end

Whitespace (spaces and tabs) is not significant. Some uses of whitespace, however, are discouraged and the compiler will generate warnings for them.

Identifiers are case-sensitive, and reserved keywords are in lowercase.

static procedure q(s : int)
	# The following variable has an acceptable name because it starts with an
	# uppercase letter. But the compiler will complain that `S' is not declared.
	var Var : int = S
end

See this page for how to write comments.

See also


Valid HTML 4.01 Strict Valid CSS!