== Extending SCL environment == The SCL values, data types etc. that are available in expressions and commands are defined in SCL modules. Currently all SCL modules must be part of the product plugins (in the future, you can also write modules inside the models). Each module is identified by a URI. SCL module is a text file ending with extension ".scl". The recommended place for modules is scl/ folder under plugin root, but also other directories can be used: scl/Test1.scl:
fib :: Integer -> Integer
fib x | x <= 1    = 1
      | otherwise = fib (x-1) + fib (x-2)
A directory is declared as a SCL package with the following kind of extension points defined in org.simantics.scl.runtime:
   
      
    
The module is not automatically available in the console, but you must run an import declaration:
> import "http://www.simantics.org/Tests/Test1" as Test1
> Test1.fib 13
377
Import declaration can also be used in modules to refer other modules. Cyclic module dependencies are not allowed. == Importing functionality from Java == Java interfaces and classes can be imported from Java by declaring them inside importJava block:
importJava "java.util.regex.Pattern" where
    data Pattern

importJava "java.util.List" where
    data List a
Java methods, constructors and fields can be similarly imported by giving their type annotations in importJava block:
importJava "java.util.regex.Pattern.compile" where
    @JavaName compile
    compilePattern :: String -> Pattern

    @JavaName matcher
    createMatcher :: Pattern -> String ->  Matcher

importJava "java.util.regex.Matcher" where
    data Matcher

    @JavaName matches
    matcherMatches :: Matcher ->  Boolean

matches : Pattern -> String ->  Boolean
matches pattern text = do
    matcherMatches (createMatcher pattern text)
Another example:
importJava "java.util.ArrayList" where
    @JavaName ""
    createArrayList :: () ->  List a

    @JavaName ""
    createArrayListWithCapacity :: Integer ->  List a

    @JavaName size
    sizeList :: List a ->  Integer

    @JavaName get
    getList :: List a -> Integer ->  a

    @JavaName set
    setList :: List a -> Integer -> a ->  ()

    @JavaName add
    addList :: List a -> a ->  Boolean
Java constructor is referred with "". If Java method name and SCL name matches the annotation @JavaName can be left out. Java import mechanism tries to be quite flexible. It provides some arguments based on the effects the function has. It also ignores the return value of the Java method if return type is () in SCL. A major functionality currently still missing is the ability to create new implementations of existing Java interfaces in SCL code or extend an existing class. This can be worked around currently by writing new implementations in Java.