Turns out what I was remembering was something like this
<https://github.com/JuliaLang/julia/blob/8e5d019f005659c5cadcd3a02651b05c7981e14d/base/combinatorics.jl#L358-L377>
for
static function variables rather than type variables. In trying to
duplicate it I run into the fact that you can't declare Types inside of
local scope:
julia> let _x = Any[]
global MyType
type MyType
data
mystatic
MyType(d) = new(d,_x)
end
end
ERROR: error compiling anonymous: type definition not allowed inside a
local scope
On Fri Jan 02 2015 at 8:19:13 PM <[email protected]> wrote:
> This seems to work, providing the equivalent to C++ class data members,
> any better suggestions?
>
> immutable MyObj_a end
>
> type MyObj
> MyObj() = new()
>
> a::Int=0
> MyObj(::Type{MyObj_a}) = a
> function MyObj(::Type{MyObj_a}, i::Int)
> a = i
> end
> end
>
> # nicer wrappers
>
> get_a(::Type{MyObj}) = MyObj(MyObj_a)
> set_a(::Type{MyObj}, i::Int) = MyObj(MyObj_a, i)
>
> # and an immutable for luck
>
> get_b(::Type{MyObj}) = 55
>
> Cheers
> Lex
>