Skip to contents

Both functions create a new Func with the given id which is afterwards accessible via .current_func(). Functions receiving a Func as an argument (such as hlo_input, hlo_add, ...) usually use .current_func() by default. You can also directly create a function using Func(), which will not be accessible this way.

Differences between the two functions:

  • local_func removes the function when exiting the current scope, whereas hlo_func does not.

  • hlo_func discards the previously built function(s), whereas local_func does not: after a function created by local_func is either cleaned up automatically (by exiting the scope) or the function is finalized via hlo_return, the previously built function is restored, i.e., accessible via .current_func(). To build nested functions (e.g. to create a closure that is passed to another op), use local_func instead of hlo_func.

Usage

hlo_func(id = "main")

local_func(id = "main", envir = parent.frame())

Arguments

id

(character(1)
The id of the function.

envir

(environment)
Environment where exit handler will be registered for cleaning up the Func if it was not returned yet.

Value

A Func object.