description |
---|
Other constructs |
To make it possible to interact with the operating system and/or the underlying runtime Bengal comes with a class that makes it possible for you to use. The capabilities of that class are limited to what the underlying operating system and/or runtime supports so this class is the only non-portable part of Bengal.
The Java integration is delivered through theJava
class. To interact with Java you would see something like the code snippet below:
String myString = "My String";
Java java = new Java();
java.callStaticMethod("java.lang.System.out.println", myString)
The code above calls the callStaticMethod
method which asks to call thejava.lang.System.out.println
static Java method and it passes myString
. Note that the implementation of the Bengal runtime converts it from the Bengal class to the corresponding Java class. The following table illustrates what conversion is done.
Bengal Class | Java Class |
---|---|
String | java.lang.String |
The Posix integration is delvered through the Posix
class. To interact with
a Posix compatible OS you would see something like the code snippet below:
String myString = "My String";
Posix posix = new Posix();
posix.call("mylib.so", "myfunction", myString);
The code above calls the call
method which asks to use the mylib.so
library
to call the myfunction
function and it passes myString
. Note that the
implementation of the Bengal runtime converts it from the Bengal class to the
corresponding Posix equivalent. The following table illustrates what conversion
is done.
Bengal Class | Posix equivalent |
---|---|
String | char* |
As the primitive types in Bengal are actually classes you will have at minimum the following classes available in any Bengal runtime.
- Boolean
- String
- Integer
- Character
- Float
- Nil
- Java (when the underlying runtime is Java)
- Posix