API's that Suck

January 2, 2010

Foundry – Unattached Functions

Filed under: Foundry — Grauenwolf @ 1:19 am

An unattached functions is a function that isn’t tied to any specific class or module. It just floats around in the global namespace. In addition to a executable’s entry point, this will be used primarily for scripting.

Action

An action is a function that doesn’t have a return value.  It has both a inline and a block form. The block terminator is very forgiving, allowing one to choose between braces or the “end” keyword. If you choose to use end, then you can optionally specify either the word “Action” or the name of the function.

<Action-Block> := <Action-Header> [ “{“ ] <EOL> <Imperative-Block> <Action-Footer>
<Action-Header> := “Action” <Identifier> <Params>
<Action-Footer> := “End” | “End Action” | End <Identifier> | “}”

The inline variant of this is detonated by  either the keyword “Then” or a colon. It allows for a single statement followed by and end-of-line token.

<Action-Inline> := <Action-Header> <Inline-Marker> <Statement> <EOL>
<Inline-Marker> := “Then” | “:”

Func

A Func is a function that has a return value.

<Func-Block> := <Func-Header> <Type> [ “{“ ] <EOL> <Imperative-Block> <Func-Footer>
<Func-Header> := “Func” <Identifier> <Params>
<Func-Footer> := “End” | “End Func” | End <Identifier> | “}”

The inline version of the Func doesn’t require a type. If not provided, it is inferred from the expression that follows.

<Func-Inline> := <Func-Header> [<Type>] <Inline-Marker> <Expression> <EOL>

Main

Main is a function that serves as the entry point for an application. By default it has an implied parameter called “args String[]” and an implied return type Int32.

<Main-Block> := “Main” [ “{“ ] <EOL> <Imperative-Block> <Main-Footer>
<Main-Footer> := “End” | “End Main” | “}”

Parameters

Obviously parameters are going to be encapsulated by parens. It is a tried and true method of handling such matters, though what goes inside the parens can vary greatly from language to language. More on this another day, its late and my brain is fuzzy.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: