Skip to content

jw3126/EponymKeywordSyntax.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EponymKeywordSyntax

Build Status Codecov

Important: This package is obsolete

On Julia 1.5 and above eponym keyword syntax is supported by the julia language directly. 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> using EponymKeywordSyntax

julia> 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)
true

julia> a=1; b=2;
2

julia> f(a=a, b=b) == @eponym f(;a,b)
true

julia> (a=a, b=b) == @eponym (;a, b)
true

julia> (a=a, b=10) == @eponym (;a, b=10)
true

julia> f(1, a=a, b=b) == @eponym f(1;a, b)
true

Acknowledgements

Based on this discussion.