Title: Add support for keyword-style arguments · Issue #245 · scijava/scijava · GitHub
Open Graph Title: Add support for keyword-style arguments · Issue #245 · scijava/scijava
X Title: Add support for keyword-style arguments · Issue #245 · scijava/scijava
Description: Some programming languages (e.g. Python) have support for keyword arguments, in addition to only ordered arguments. Furthermore, in Python at least, one can have a function with keyword only arguments, which can happen if an argument fol...
Open Graph Description: Some programming languages (e.g. Python) have support for keyword arguments, in addition to only ordered arguments. Furthermore, in Python at least, one can have a function with keyword only argume...
X Description: Some programming languages (e.g. Python) have support for keyword arguments, in addition to only ordered arguments. Furthermore, in Python at least, one can have a function with keyword only argume...
Opengraph URL: https://github.com/scijava/scijava/issues/245
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add support for keyword-style arguments","articleBody":"Some programming languages (e.g. Python) have support for keyword arguments, in addition to only ordered arguments. Furthermore, in Python at least, one can have a function with [keyword only arguments](https://peps.python.org/pep-3102/), which can happen if an argument follows the varargs `*args` syntax, or in general for the `**kwargs` syntax. In either situation, the name of the parameter must be given along with the intended value.\r\n\r\nSciJava Ops currently does not have a feature like this, but it could. Here is one possible syntax:\r\n\r\n```java\r\nImg image = ...;\r\ndouble sigma = ...;\r\nImg result = ...;\r\nComputers.Arity2\u003cImg, Double, Img\u003e gaussOp =\r\nops.op(\"filter.gauss\")\r\n .input(\"image\", image)\r\n .input(\"sigma\", sigma)\r\n .output(result)\r\n .computer();\r\n```\r\n\r\nIn the example above, the `image` and `sigma` parameters are individually given by separate `.input(name, value)` calls. A big advantage of this design is that it preserves the type safety offered by Ops. A downside is that the `OpBuilder` infrastructure would need to expand a lot to accommodate it. Another difficulty is that the op matching engine is currently fully built around the idea of ordered parameters, and it would need refactoring to support op requests with unordered+named inputs. But all of that could certainly be done with effort.\r\n\r\nThis goal of supporting op matching by named inputs would make it more elegant to wrap such Python functions into Ops. But even with it in place, Ops does not support varargs and might never do so, since it weakens type safety.","author":{"url":"https://github.com/ctrueden","@type":"Person","name":"ctrueden"},"datePublished":"2024-07-29T17:26:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/245/scijava/issues/245"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3a7640cb-5c4d-dfae-9e71-8cd8f5a8fc6f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD64:2A6D10:4F3CCC:652BA4:696AE3B8 |
| html-safe-nonce | ad612989071f3a217afb86735d7ca85825e4c60416433b048cd85e035908a9ee |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDY0OjJBNkQxMDo0RjNDQ0M6NjUyQkE0OjY5NkFFM0I4IiwidmlzaXRvcl9pZCI6IjMyOTU5NzI4ODU1NjQ5NDEyNDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5d2c1924f744587e04e443424c9441333fc5a828dcd91dbda0be364f92db0403 |
| hovercard-subject-tag | issue:2435957593 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/scijava/scijava/245/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7451c7133dd99b54391126950b50ea12527ecd53b1409270a2c60f4da76701b5/scijava/scijava/issues/245 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7451c7133dd99b54391126950b50ea12527ecd53b1409270a2c60f4da76701b5/scijava/scijava/issues/245 |
| og:image:alt | Some programming languages (e.g. Python) have support for keyword arguments, in addition to only ordered arguments. Furthermore, in Python at least, one can have a function with keyword only argume... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ctrueden |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/scijava/scijava git https://github.com/scijava/scijava.git |
| octolytics-dimension-user_id | 1262770 |
| octolytics-dimension-user_login | scijava |
| octolytics-dimension-repository_id | 85618439 |
| octolytics-dimension-repository_nwo | scijava/scijava |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 85618439 |
| octolytics-dimension-repository_network_root_nwo | scijava/scijava |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3d84d50b3c75fa36755c3cf392edbc09e626f979 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width