## ŒEVAL Evaluate external expression

The dyadic system function ŒEVAL allows you to evaluate an arbitrary expression in an external object-oriented environment, provided the architecture supports it.

The left argument is a character vector which specifies the external environment in which you want to evaluate the expression, in the same format as for ŒNEW. The right argument is a character vector containing an expression which is valid in the target environment.

The main use for ŒEVAL is for running code is an interpreted language such as Ruby or R, and for setting up variables in the Ruby environment:

          'ruby' ŒEVAL 's=String.new "Hello there"'
    Hello there
          'ruby' ŒEVAL 's.length'
    11
          'ruby' ŒEVAL 'Math.sqrt(9)'
    3

This example shows in the R environment:

          r„'r' Œnew 'r'
          r.x„2 3½¼6         © x is an R variable
          r.x
    1 2 3
    4 5 6

          'r' Œeval 'x[2,]'
    4 5 6
          'r' Œeval 'mean(x[2,])'
    5

Note that the last line could be executed using the alternative syntax:

          r.Œeval 'mean(x[2,])'
    5

ŒEVAL is not supported for .Net or Java:

          '.net' ŒEVAL '2+2'
    Library for architecture '.net' does not support direct evaluation
    DOMAIN ERROR
          '.net' ŒEVAL '2+2'
          ^

See also ŒCALL, which allows you to call arbitrary 'static' methods in external environments, and the system-method form of ŒEVAL for R.

Topic: APLX Help : Help on APL language : System Functions & Variables : ŒEVAL Evaluate external expression

[ Previous | Next | Contents | Index ]