Rhope Blog

Blog Home Downloads Documentation RSS

Getting Started with Rhope: Syntax

by Mike Pavone

This is designed to be a brief introduction to the syntax of the Rhope programming language for those with prior programming experience. A proper tutorial will be coming a bit later. The software running this blog doesn't currently support marking up preformatted text so I'm going to try and keep the inline examples to a minimum. Check out the downloads section for a few small example programs.

Let's start with the obvious syntax differences. I made some rather... interesting choices for punctuation in the language. Some of this will probably be cleaned up in a future release, but this post will be focusing on the here and now. |: (that's a pipe followed by a colon) is roughly analogous to a left curly bracket ({) in C-like languages and :| (a colon followed by a pipe) is roughly analogous to a right curly bracket (}) in C-like languages. Square brackets take the place of parentheses, but are only used for worker invocation (Rhope's funny name for functions/procedures). Curly brackets are only used to denote List literals. String literals are almost the same as in C, but the \x escape sequence is not supported. Assignment is done with <- (a less than symbol followed by a dash) and testing for equality is done with = (technically = is a worker and not part of the syntax).

Inputs to a worker work a bit differently than most languages in Rhope. Instead of declaring the names of the inputs up front, you instead declare how many inputs and how many outputs a worker has. Inputs and outputs are then referred to by their position with a number in parentheses. (0) refers to the first input or output (whether it refers to an input or output depends on context), (1) the second and so on. To make this a bit more readable, you can stick text in front of this number in parentheses like so: some string(0).

Identifiers can have spaces in them and internal white space is considered significant, but white space at the beginning or end of an identifier is ignored. So Get Stuff[] and GetStuff[] are not the same. Rhope is currently case sensitive. My current convention is title case for workers and companies (Rhope's funny name for classes/types) and lower case for inputs, outputs and variables, but this is not required by the language.

There are no operators (apart from assignment) in Rhope. Operations like + and - are just workers. Workers can be called with the worker name in the prefix, postfix and infix positions in relation to the arguments. So if you want to add 1 and 1, you could do: +[1,1] or [1,1]+ or [1] + [1]. There is no restriction on how many of the inputs are in each of the input groups in the infix case. There is no special syntax for method calls. [list]Index[0] (or Index[list, 0] or [list, 0]Index) will do a generic method call using the first argument (in this case list) to determine which company's method should be called. To call a method of a specific company in a non-generic fashion use the fully qualified name (the method name, followed by the @ symbol followed by the company name) like so: [list]Index@List[0].

That covers most of the oddities in Rhope's syntax. The next post will give a brief overview of some of the major semantic differences between Rhope and most imperative languages.

comment by '

<b>this is a comment alright!

Username: Password:
Don't have an account? Register now!