Skip to end of metadata
Go to start of metadata

As a static scope language, Jaskell supports dynamic scope with a few functions.

  • define is the fundamental function that enables dynamic scope.
    With define, one can place a java.util.Map or a tuple as the scope and all the members in the map or tuple are automatically visible to the following expression. For example:
    Though straight-forward, the above example isn't normally very useful. We could always use:
    Yet, define and its variants are more useful when the scope is dynamically determined. For example, the tuple or map can be provided by user at runtime.
  • with is a function derived from define. It is used to make visible all public methods and fields of an object to the following expression.
    For example:
    is equivalent to the following java code:
    If you are familiar with the Basic language, this is essentially the "with" statement that allows us to invoke methods without explicitly writing down the object again and again.
  • do is another function derived from define. It is to mimic the monadic do notation where higher-order monadic combinators can be combined in an intuitive syntax. For example:
Labels: