Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jw3126/eponymkeywordsyntax.jl
Function calls with 50% less typing ;-)
https://github.com/jw3126/eponymkeywordsyntax.jl
julia keyword-arguments macros shorthand-syntax
Last synced: 21 days ago
JSON representation
Function calls with 50% less typing ;-)
- Host: GitHub
- URL: https://github.com/jw3126/eponymkeywordsyntax.jl
- Owner: jw3126
- License: mit
- Created: 2019-12-11T21:17:35.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-29T15:37:16.000Z (over 3 years ago)
- Last Synced: 2024-10-12T07:35:28.843Z (about 1 month ago)
- Topics: julia, keyword-arguments, macros, shorthand-syntax
- Language: Julia
- Homepage:
- Size: 14.6 KB
- Stars: 12
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EponymKeywordSyntax
[![Build Status](https://travis-ci.com/jw3126/EponymKeywordSyntax.jl.svg?branch=master)](https://travis-ci.com/jw3126/EponymKeywordSyntax.jl)
[![Codecov](https://codecov.io/gh/jw3126/EponymKeywordSyntax.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/jw3126/EponymKeywordSyntax.jl)# Important: This package is obsolete
On Julia 1.5 and above eponym keyword syntax is [supported by the julia language directly](https://github.com/JuliaLang/julia/pull/34331).
Older Julia versions can get it from Compat.jl. So EponymKeywordSyntax is not needed anymore.# Usage
This package provides the `@eponym` macro, which infers the name of a keyword argument
from the name of its value. This is best explained by example:
```julia
julia> using EponymKeywordSyntaxjulia> f(args...; kw...) = (args=args, kw=kw)
f (generic function with 1 method)julia> oh_dear_this_is_long_I_dont_want_to_write_it_twice=3
3
julia> f(oh_dear_this_is_long_I_dont_want_to_write_it_twice=oh_dear_this_is_long_I_dont_want_to_write_it_twice) == @eponym f(;oh_dear_this_is_long_I_dont_want_to_write_it_twice)
truejulia> a=1; b=2;
2julia> f(a=a, b=b) == @eponym f(;a,b)
truejulia> (a=a, b=b) == @eponym (;a, b)
truejulia> (a=a, b=10) == @eponym (;a, b=10)
truejulia> f(1, a=a, b=b) == @eponym f(1;a, b)
true
```# Acknowledgements
Based on [this](https://discourse.julialang.org/t/keyword-arguments-without-a-keyword/31863/1) discussion.