{"id":29132240,"url":"https://github.com/beforerr/permuteargs.jl","last_synced_at":"2025-06-30T06:37:36.643Z","repository":{"id":263491101,"uuid":"889797569","full_name":"Beforerr/PermuteArgs.jl","owner":"Beforerr","description":"Generate multiple method definitions allowing arbitrary argument order based on types","archived":false,"fork":false,"pushed_at":"2025-04-21T15:35:28.000Z","size":47,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-21T18:08:35.572Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Beforerr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-17T09:05:35.000Z","updated_at":"2025-04-21T15:17:48.000Z","dependencies_parsed_at":"2025-01-31T08:18:24.918Z","dependency_job_id":"0a487124-e85d-4de8-b24a-17b826e33728","html_url":"https://github.com/Beforerr/PermuteArgs.jl","commit_stats":null,"previous_names":["beforerr/permuteargs.jl"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Beforerr/PermuteArgs.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beforerr%2FPermuteArgs.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beforerr%2FPermuteArgs.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beforerr%2FPermuteArgs.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beforerr%2FPermuteArgs.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Beforerr","download_url":"https://codeload.github.com/Beforerr/PermuteArgs.jl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beforerr%2FPermuteArgs.jl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262725294,"owners_count":23354451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-30T06:37:35.924Z","updated_at":"2025-06-30T06:37:36.633Z","avatar_url":"https://github.com/Beforerr.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PermuteArgs.jl\n\n[![Build Status](https://github.com/Beforerr/PermuteArgs.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/Beforerr/PermuteArgs.jl/actions/workflows/CI.yml?query=branch%3Amain)\n\nA Julia package that provides tools for creating functions with permutable arguments:\n- `@permute_args`: Macro to define functions with permutable arguments\n- `permute_args`: Function to create a new function with permutable arguments\n- `permute_args!`: Function to add permuted methods to an existing function\n\n`@permute_args` is recommended over `permute_args` and `permute_args!` as it comes with no runtime overhead.\n\n## Installation\n\nYou can install PermuteArgs using Julia's package manager:\n\n```julia\nusing Pkg\nPkg.add(\"PermuteArgs\")\n```\n\n## Features\n\n- Supports both multi-line and one-line function definitions\n- Supports struct definitions with permutable fields\n- Handles keyword arguments\n- Maintains type safety\n- Generates all possible permutations of argument orders\n\n## Usage\n\n### Using the Macro\n\nThe `@permute_args` macro allows you to define functions and structs where arguments/fields can be provided in any order, as long as their types match the signature:\n\n```julia\nusing PermuteArgs\n\n# Define a function with permutable arguments\n@permute_args function test_func(x::Int, y::String)\n    return \"x=$x, y=$y\"\nend\n\n# Call the function with arguments in any order\ntest_func(42, \"hello\")      # Returns: \"x=42, y=hello\"\ntest_func(\"hello\", 42)      # Returns: \"x=42, y=hello\"\n\n# Define a struct with permutable fields\n@permute_args struct TestStruct\n    x::Int\n    y::String\nend\n\n# Create struct instances with fields in any order\nTestStruct(42, \"hello\")      # TestStruct(42, \"hello\")\nTestStruct(\"hello\", 42)      # TestStruct(42, \"hello\")\n```\n\n### Using the Function\n\nThe `permute_args` function creates a new function that accepts permuted arguments:\n\n```julia\n# Define base function\nfunction base_func(x::Int, y::String)\n    return \"x=$x, y=$y\"\nend\n\n# Create permutable version\npermuted_func = permute_args(base_func, [Int, String])\n\n# Call with different argument orders\npermuted_func(42, \"hello\")      # Returns: \"x=42, y=hello\"\npermuted_func(\"hello\", 42)      # Returns: \"x=42, y=hello\"\n```\n\nType arguments can be omitted and the first method of the function will be used instead.\n\n```julia\npermuted_func = permute_args(base_func)\n```\n\n### Modifying Existing Functions\n\nThe `permute_args!` function adds permuted methods to an existing function:\n\n```julia\n# Define base function\nfunction test(x::Int, y::String)\n    return \"x=$x, y=$y\"\nend\n\n# Add permuted methods\npermute_args!(test, [Int, String])\n\n# Now can call with different argument orders\ntest(42, \"hello\")      # Returns: \"x=42, y=hello\"\ntest(\"hello\", 42)      # Returns: \"x=42, y=hello\"\n```\n\n### With Keyword Arguments\n\nThe macro also supports functions with keyword arguments:\n\n```julia\n@permute_args function keyword_func(x::Int, y::String; z::Float64=3.14)\n    return \"x=$x, y=$y, z=$z\"\nend\n\n# Call with default keyword argument\nkeyword_func(42, \"hello\")                 # Returns: \"x=42, y=hello, z=3.14\"\nkeyword_func(\"hello\", 42)                 # Returns: \"x=42, y=hello, z=3.14\"\n\n# Call with specified keyword argument\nkeyword_func(42, \"hello\", z=2.71)         # Returns: \"x=42, y=hello, z=2.71\"\nkeyword_func(\"hello\", 42, z=2.71)         # Returns: \"x=42, y=hello, z=2.71\"\n```\n\n### One-line Function Definitions\n\nThe macro works with both multi-line and one-line function definitions:\n\n```julia\n@permute_args one_line_func(x::Int, y::String) = \"x=$x, y=$y\"\n```\n\n## Error Handling\n\nThe package maintains Julia's type safety. Attempting to call a function with incorrect types will raise a `MethodError`:\n\n```julia\ntest_func(1.0, \"hello\")      # Throws MethodError: wrong type for x\ntest_func(\"hello\", \"world\")  # Throws MethodError: wrong type for y\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeforerr%2Fpermuteargs.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeforerr%2Fpermuteargs.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeforerr%2Fpermuteargs.jl/lists"}