MemberFunctions.jl

`MemberFunctions.jl` helps writing member-like functions, reducing the amount of code required to implement them.
Author tehrengruber
Popularity
0 Stars
Updated Last
3 Years Ago
Started In
May 2019

MemberFunctions.jl

MemberFunctions.jl helps writing member-like functions, reducing the amount of code required to implement them. All functions prefixed by the @member macro can access, i.e. read and write, fields of the first argument directly.

Example

mutable struct Foo
  value
end

@member get_value(foo::Foo) = value

@member function set_value!(foo::Foo, v)
  value = v
end

foo = Foo(1)
set_value!(foo, 2)

get_value(foo) == 1

set_value!(foo, 2)
get_value(foo) == 2

Required Packages

Used By Packages

No packages found.