Returning multiple outputs with get #1
Labels
No labels
bug
duplicate
enhancement/documentation
enhancement/feature
enhancement/organization
question
rejected
upstream
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
UserCurt/mpath#1
Loading…
Reference in a new issue
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?
It can be useful to return multiple values simultaneously, for simultaneous assignment for example.
The means to indicate when or how multiple outputs is handled is not yet determined. There are a couple options:
Named Argument: One option is to have a named argument that says which dimension(s) will be collapsed and used for multiple outputs. What name to use is not yet determined. This is nice because it does not require changing syntax. But it can be confusing because automatically assigned dimensions may be unclear. Perhaps this should only work with manually applied dimensions.
New Syntax: Alternatively, new syntax can be introduced. Two contenders are to modify the dimension specifier notation to follow by a keyword:
mpath.get(S, "/*#list"). The term "list" is used to concisely mirror Mathwork's usage of the phrase comma separated list while not being verbose or using abbreviations. Alternatively, the#symbol can be repeated:mpath.get(S, "/*##"). In my opinion, this looks weird and could be misconstrued as a typo.If introducing new syntax, it is unclear how this will interact with
mpath.resolve,mpath.set,mpath.remove,mpath.exist. What behavior would be expected? Should it give an error? Should it act just like any other dimension?Ideally, there would be a mechanism for the order in which the outputs are selected, but this isn't critical for the feature. If using a named argument, this could be determined by the order of the dimensions. Here, I use
OutputDimsas the named argument. A few examples:This could also be used in
mpath.resolve:Regarding
mpath.set, this could be considered as the sole means for simultaneous assignment, akin to comma separated list assignments. Though there could be accidental assignments when working with heterogeneous data that happen to have the correct number of items in the comma separated list. For example, you can have 6 outputs equally from 2×3 or 3×2, and since the assignment wouldn't really have a shape, there is no error checking. Though withOutputDims, there could be a theoretical "shape" to this that could be checked.