webr icon indicating copy to clipboard operation
webr copied to clipboard

When Typescript 5.2 is released, consider updating and using the new `using` keyword.

Open georgestagg opened this issue 1 year ago • 1 comments

The new using keyword could give us a nicer way to manage R object memory. What is currently,

try {
  const foo = await webR.evalR('foo');
} finally {
  webR.destroy(foo);
}

could become something like,

{
  await using foo = webR.evalR('foo');
  // Do something with foo...
} // Automatically destroyed!

The finaliser is defined in a special symbol property of the object foo, so IIUC we would "just" need to include a new property in the generic RObject proxy object hooks.

georgestagg avatar Jun 21 '23 09:06 georgestagg

oooh nice!

lionel- avatar Jun 21 '23 09:06 lionel-