Skip to content

RW support for function handles#232

Merged
matthijscox merged 5 commits intoJuliaIO:masterfrom
foreverallama:funchandle
Feb 6, 2026
Merged

RW support for function handles#232
matthijscox merged 5 commits intoJuliaIO:masterfrom
foreverallama:funchandle

Conversation

@foreverallama
Copy link
Contributor

@foreverallama foreverallama commented Dec 10, 2025

Reference: #221

  • Added new basic type FunctionHandle
  • Read support in v7 and HDF formats
  • Updated test for function_handles.mat to reflect new type

TODO: Add write support

If the new type is sufficient then I'll move on to writing.

* MAT_HDF: New method m_write() to write function handles
* MAT_HDF: New constants for MATLAB_object_decode 1 to 3
* write.jl: Add RW test
* read.jl: Remove standalone read test
* MAT_subsys: Fix for writing MatlabOpaque objects with object ID = 0
* MAT_subsys: Added class "function_handle_workspace" to list of saveobj classes
* MAT_subsys: Fix for serializing nested objects
@foreverallama
Copy link
Contributor Author

Added write support for function handles

  • Removed standalone read test and incorporated it into write.jl as its easier to read then write.
  • Added constants for the MATLAB_object_decode attribute

Some types of function handles use opaque objects which revealed some bugs which has been fixed:

  • Fix: Writing objects with an object ID = 0
  • Fix: Serializing nested properties uses a copy for structs/cells to avoid overwriting the property value with object metadata. I think the copy is cheap as it should be copying references. Now we're only modifying the copy with nested object metadata (if any) instead.

These bugs are implicitly tested with RW for function handles.

I think the FunctionHandle type can be extended as a Dict like the other types. It'll keep things uniform

@foreverallama
Copy link
Contributor Author

It might be a good idea to change the type of MatlabFunction to resemble MatlabClassObject don't you think (emulating the dict behaviour)?

@foreverallama
Copy link
Contributor Author

Updated FunctionHandle as subtype of AbstractDict. Updated tests to reflect this. I think this is wrap

@matthijscox
Copy link
Member

yeah looks good to me, if you want I can merge.

Since there are no other PRs ready to merge, it's even easiest if you do a package version bump in this PR to 0.11.5, then I can register right after merging this PR.

@matthijscox matthijscox merged commit 1135260 into JuliaIO:master Feb 6, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants