Upgrading Your Program To Orc 2.0#

Orc 2.0 improves the syntax of the Orc language in many ways, but some of these changes require existing Orc programs to be modified. Here is a topical list of the most significant such changes. The full list of what's new in Orc 2.0 is in Orc 2.0 Release Notes.

Comparison#

  • Less than < and greater than > have changed to <: and :> to remove ambiguity with the pruning and sequential combinators.

If Then Else#

  • Some uses of if then else that were previously un-parenthesised may now require parenthesis. (The special parser rules regarding if then else and the sequential combinator >> have been removed.)
  • The undocumented option to omit the else clause has been eliminated.
  • The if site has been renamed to Ift.

Site Names#

  • All library site names are consistently capitalized. Sites that predated this convention have been brought into conformance: Let, Print, Println, Error, Read, Write, Floor, Ceil, Random, URandom.
  • Some library sites have been renamed for clarity and consistency:
    • IArray is now Table.
    • Rtimer is now Rwait. Clock is now Rclock.
    • Buffer is now Channel. BoundedBuffer is now BoundedChannel.
    • "Nonblocking" sites, with the suffix "nb", are now "definite" sites, with the suffix "D".

Def Body Parsing Ambiguity#

This program excerpt could be parsed in two ways:

def f() = 1
- 2
Namely, as a def with a body 1 - 2, or with a body 1, followed by a goal expression -2.
  • Previously, the parser treated newlines specially to try to disambiguate these cases. That has been removed, because it imposed surprising-to-new-users restrictions on the placement of newlines.
  • This ambiguity happens most commonly with goal expressions that start with a parenthesis ( or a minus -.
  • To eliminate the ambiguity, one can add a signal >> to the beginning of the goal expression.
def f() = 1
signal >> - 2

Definitions and Imports#

  • The import declarations for site, class, and type are now preceded by the keyword import and the Java class name is quoted. For example, import class TreeSet = "java.util.TreeSet".
  • def capsule is now def class.

Patterns#

  • The equality =x pattern is gone. Use the new guard feature instead, for example, def f(x,y) if (x = y) = ....

Arrays#

  • Arrays have no methods, and have only a length field.
    • The get and set methods are replaced by the use of elements as Refs (see below).
    • The slice and fill methods are replaced by the library functions sliceArray and fillArray.
    • The length method is replaced by the length field, accessed as length?.
  • Array elements are Refs, so they are read like a(3)? and written like a(3) := 5.

Currying#

  • The currying syntactic form was removed, since it held traps for the unwary -- it implicitly made functions strict. It also distractingly complicated the presentation of the language's syntax.
  • Replace currying with explicit uses of lambda.

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-10) was last changed on 20-Apr-2011 14:59 by JohnThywissen