Rowan home > Language elements
Rowan Language Elements
This document describes the language elements and the syntax of Rowan.
Basic Elements
These are the basic elements that make up the Rowan language.
- Noun: a constant value (
23
or "Hello"
) or a variable.
- Function or Verb: takes data (in the form of nouns) and manipulates it in some way to produce new data. There are many built-in functions (
+
, ×
etc; see the Reference), and you can write your own ({(+/⍵)÷⍴⍵}
). Functions can be niladic (taking no arguments), monadic (taking a right argument) or dyadic (taking a left and a right argument); see below.
- Operator: takes a function and manipulates it in some way to produce a new function. Operators can be monadic (taking a left operand) or dyadic (taking a left and a right operand).
- Conjunction: takes a function and a noun and manipulates them to produce a new function.
- Invocation: calls functionality defined in the .Net Framework or in external assemblies.
Syntax
Rowan syntax is determined by a series of language patterns defined in the parse table of the interpreter. If a statement cannot be matched at each point in time by one of the patterns somewhere along its length, it is invalid and a SyntaxException is thrown.
- DyadVerb: noun verb noun -> noun
Example: 3 + (4 5)
Calls the verb dyadically. If the verb doesn't have a dyadic definition, it is a syntax error.
- MonadVerb: verb noun -> noun
Example: ⍳10
; {(+/⍵)÷⍴⍵} data
Calls the verb monadically. If the verb doesn't have a monadic definition, it is a syntax error.
- DyadOperator: verb op verb -> verb
Example: {(⍵%3)-(⍺%3)}⌾⍒
Creates a derived function related to the two original functions. If the operator is not dyadic, it is a syntax error.
- MonadOperator: verb op -> verb
Example: +/
; ?⍨
Creates a derived function related to the original function. If the operator is not monadic, it is a syntax error.
- Conjunction: verb conj noun -> verb or noun conj verb -> verb
Example: ×^(0 1)
Creates a derived function related to the original function, modified depending on the noun.
- InvokeMonad: noun invoc noun -> [noun]
Example: 140:ToString "X4"
Calls a method in the .Net Framework or external assembly with the specified arguments. If the method returns a result, a noun replaces the expression, otherwise nothing does.
- InvokeNilad: noun invoc -> [noun]
Example: form:Show
Calls a method or reads a propety in the .Net Framework or external assembly, with no arguments. If the method returns a result, a noun replaces the expression, otherwise nothing does.
- InvokeAssign: noun invoc asgn noun -> noun
Example: form:Opacity←0.6
Sets a property in the .Net Framework or external assembly.
- Nilad: verb -> [noun]
Runs a function that expects no arguments.
- Assign: name asgn any -> any
Example: a←12
; f⍅{x: x²}
Assigns the value to the name, so when you use that name later the value will be substituted. You can assign values of any type to a name at any time, so you can overwrite a function with a noun, for example.
- ModifyAndAssign: noun verb asgn any -> any
Example: a+←12
Modifies the value associated with the name.