with_jlview: Use a jlview object within a scope, releasing it on exit

View source: R/release.R

with_jlviewR Documentation

Use a jlview object within a scope, releasing it on exit

Description

Creates a jlview object and ensures it is released when the scope exits, even if an error occurs. This prevents memory leaks from forgotten releases.

Usage

with_jlview(
  julia_array,
  expr,
  writeable = FALSE,
  names = NULL,
  dimnames = NULL
)

Arguments

julia_array

A JuliaObject referencing a Julia array

expr

An expression to evaluate with the jlview object bound to .x

writeable

Passed to jlview

names

Passed to jlview

dimnames

Passed to jlview

Value

The result of evaluating expr

Examples

## Not run: 
JuliaCall::julia_setup()
JuliaCall::julia_command("big = randn(100000)")
result <- with_jlview(JuliaCall::julia_eval("big"), {
    c(mean(.x), sd(.x))
})
# .x is automatically released here

## End(Not run)

jlview documentation built on March 24, 2026, 1:07 a.m.