Go to the first, previous, next, last section, table of contents.


EQGUILE

Works identically to EQUATE except that it defines an equate that is written in scheme to be run under the GUILE interpreter. The grg program must have been compiled with support for GUILE otherwise this macro will be treated the same as EQUATE.

There should be one macro argument to be the name of the equate as seen from the GRG side. This is so that the equate can be called from the GRG side as if it was any other equate. Any number of optional whitespace separated arguments may also be given to this macro (after the name). Any arguments passed to the equate from the GRG side will be passed to the function on the GUILE side. No error checking is done. Argument types are converted in a limited sense to the GUILE side equivalent. An equate defined in scheme is only allowed to return one argument and the GRG side will pick this up, convert the type and it can be used as normal. Only simple numbers and strings should be returned from the GUILE side.

Here is the definition of factorial as an equate written in scheme.

%%EQGUILE fact n
  (if (= n 1) 1 (* n (fact (- n 1))))

This will be wrapped up on the GUILE side as shown below.

(define (fact n) (if (= n 1) 1 (* n (fact (- n 1)))))

It can be called in exactly the same way as any other equate.

%%EQUATE FUBAR
  OUTPUTS(fact(4))
%%RECORD
Direct call: ... #fact(2) ... and then via another equate: ... #FUBAR ...

There are some additional procedures made available under the GUILE side from the GRG side, see section Using GUILE for more details.


Go to the first, previous, next, last section, table of contents.