1.11. External Values

Orc's value set is "open" — any value returned from a site call can be used in an Orc execution. For example, Orc programs running on a Java virtual machine (JVM) can interact with any Java object.

1.11.1. Type

External values usually have types that cannot be represented using Orc's primitive types or structured types. An import type declaration may be used to import such a type into the Orc type system.

1.11.2. Examples

Java BitSet
{- Using the Java class java.util.BitSet,
   construct a new instance, and then
   set bits 2 and 4 in the BitSet instance
-}

import class BitSet = "java.util.BitSet"

BitSet() >b> b.set(2) >> b.set(4) >> b.toString()

{-
OUTPUT:
"{2, 4}"
-}
Java HashMap
{- Using the Java class java.util.HashMap, construct a new instance, 
   and then put and get some entries
-}

import class HashMap = "java.util.HashMap"

HashMap[String, String]() >m> m.put("Mickey", "Minnie") >> 
m.put("Donald", "Daisy") >> m.get("Mickey")

{-
OUTPUT:
"Minnie"
-}

1.11.3. Related Links

Related Tutorial Sections