4.7. include: Include Orc File

It is often convenient to group related declarations into units that can be shared between programs. The include declaration offers a simple way to do this. It names a source file containing a sequence of Orc declarations; those declarations are incorporated into the program as if they had textually replaced the include declaration. An include declaration may occur wherever any other declaration occurs, even in a nested scope. An included file may itself contain include declarations. Included files may come from local files, any URI recognized by the Java library (http, https, ftp, etc.), and include resources found in the Orc JAR files.

4.7.1. Syntax

[28]DeclareInclude::= include FileName  

4.7.2. Examples

fold.inc,used below
{- Contents of fold.inc -}

def foldl(f,[],s) = s
def foldl(f,h:t,s) = foldl(f,t,f(h,s))

def foldr(f,l,s) = foldl(f,rev(l),s)
Include a separate file
{- This is the same as inserting the contents of fold.inc here -}
include "fold.inc"

def sum(L) = foldl(lambda(a,b) = a+b, L, 0)

sum([1,2,3])

4.7.3. Related Links

Related Reference Topics

Related Tutorial Sections