1
0
Fork
You've already forked mpath
0

Create new fields using set #10

Open
opened 2025年10月11日 11:23:01 +02:00 by UserCurt · 1 comment

Normally, mpath.set will assign the value to existing fields. This feature request is to allow mpath.set and mpath.Pointer.set create new fields in structs, variables in tables, and properties in classes with dynamic properties. Usage of mpath.exist from #8 should return true after mpath.set.

Some care may be considered to avoid accidentally creating new fields unintentionally. Perhaps by default attempting to create new fields should result in an error. Providing a named argument CreateNewFields when true would allow creation of new fields.

There is a subtlety to note with two separate behaviors: Creating a new field on an existing struct, or creating a new struct on an existing struct. It is probably best to lump these together with CreateNewFields rather than having each be optional.

Implementation of this feature as proposed would promote structs to be treated specially over tables as, without additional work, it would not be possible to create new variables (columns) in tables using mpath. Some consideration should be put into alternative ways that would treat these more equally.

Normally, `mpath.set` will assign the value to existing fields. This feature request is to allow `mpath.set` and `mpath.Pointer.set` create new fields in structs, variables in tables, and properties in classes with [dynamic properties](https://www.mathworks.com/help/matlab/matlab_oop/dynamic-properties-adding-properties-to-an-instance.html). Usage of `mpath.exist` from #8 should return true after `mpath.set`. Some care may be considered to avoid accidentally creating new fields unintentionally. Perhaps by default attempting to create new fields should result in an error. Providing a named argument `CreateNewFields` when true would allow creation of new fields. There is a subtlety to note with two separate behaviors: Creating a new field on an existing struct, or creating a new struct on an existing struct. It is probably best to lump these together with `CreateNewFields` rather than having each be optional. Implementation of this feature as proposed would promote structs to be treated specially over tables as, without additional work, it would not be possible to create new variables (columns) in tables using mpath. Some consideration should be put into alternative ways that would treat these more equally.
Author
Owner
Copy link

This feature is pending the completion of #11.

This feature is pending the completion of #11.
Sign in to join this conversation.
No Branch/Tag specified
main
dev
functional
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
UserCurt/mpath#10
Reference in a new issue
UserCurt/mpath
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?