Sunday, November 11, 2012

Types

Here is a list for the types I envision for my language.

Core Types

Core types are those that are integrated into the language. They do more than simply hold data; they have an influence on how the app runs.

Boolean

Booleans are used in the if statement.

List

Lists are used in subroutines calls for their parameters and returned values.

Any

Any is used to indicate that any type is acceptable. Since a core type can be use for it, it too must be a core type.

Code

Subroutines are first-class citizen of the language. This means they can be passed around by other subroutines and stored in variables. Since they can also be executed, they are core types.

Common Types

These types are used for most programming requirements.

Text

Text types hold a sequence of characters. They also have an encoding and a locale. They can be parsed by Rules.

Number

The number type is for arithmetic. Numbers are stored as BCD or decimal-floating point. This is to prevent non-integer numbers from doing unexpected truncations.

Records

Records are programmer-defined types. They allow the app to build complex, tree structures.

Note that they cannot build cyclic-structures or even DAGs. This may seems a sever limitation but XML can only build trees too. To build more complex structures, do what XML does: use indirect references.

Weird Types

These types were developed by the computer science community. As such, the novice programmer is unfamiliar with them. This could be a good thing and a bad thing. It's good because they have no expectations of them and no hindrance to learning. It's bad because they have to learn everything from scratch.

String

Strings hold a sequence of bytes. They can be parsed by formal regular expressions. They can be pack or unpack, that is, a subsequence of bytes can be convert to and from other types.

Streams: File, Folder, Pipe, Socket, Terminal

Streams are used for I/O. They often have an internal state; this is called being mutable. Because they are mutable, they cannot be used as subroutine arguments or return values.

Streams work with Text and Numbers, which covers the majority of all I/O. But sometimes, it needs to read and write Strings, raw sequences of bytes.

Rules

Rules are Perl-compatiable regular expressions (PCRE). They can be passed around by subroutines. They are used to parse Text. Although they are called regular expressions, they are not; they are much more expressive and powerful. Perhaps they should be called Irregular Expressions. ☺

Because they can also be executed, they are core types. But since mastering them is a separate endeavour, I placed them in this section.

Plug-in Types

Plug-in types can be used to extend the language. They replace operator overloading in other languages. But unlike operator overloading, they are not stuck with the syntax and semantics of the language; they can define they own.

Complex Numbers, Matrices

Formulas of these types use the common arithmetic syntax.

Integers, Date & Times, Money, Intervals, Units

These place restrictions on the standard types and may require special formatting and parsing when used with I/O.

Associated Lists

Since I'm a Perl Monger, I'm used to having associated lists, or hashes as they are known as in the Perl community. So, I couldn't create a language without them. ☺