gcalderone / reusepatterns.jl Goto Github PK
View Code? Open in Web Editor NEWImplement composition and concrete subtyping in Julia.
License: MIT License
Implement composition and concrete subtyping in Julia.
License: MIT License
Consider the following:
mwe
using ReusePatterns
struct MyArray{T, N} # <: AbstractArray{T, N}
a::Array{T, N}
attr::Int
MyArray(T, dims::NTuple{N, Int}) where {N} = new{T, N}(zeros(T, dims...), 1)
end
@forward((MyArray, :a), Array)
main() = begin
a = MyArray(Float64, (2, 2, 2))
@show size(a)
return
end
main()
It fails with:
ERROR: LoadError: MethodError: no method matching eval(::Expr)
You may have intended to import Base.eval
Closest candidates are:
eval(::Module, ::Any) at boot.jl:368
Stacktrace:
[1] (::ReusePatterns.var"#newmethod#2")(sender_type::String, sender_symb::String, argid::Vector{Int64}, method::Method, withtypes::Bool, allargs::Bool)
@ ReusePatterns [...]/ReusePatterns.jl/src/ReusePatterns.jl:60
[2] forward(sender::Tuple{UnionAll, Symbol}, receiver::Type, method::Method; withtypes::Bool, allargs::Bool)
@ ReusePatterns [...]/ReusePatterns.jl/src/ReusePatterns.jl:104
[3] forward
@ [...]/ReusePatterns.jl/src/ReusePatterns.jl:45 [inlined]
[4] forward(sender::Tuple{UnionAll, Symbol}, receiver::Type; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ ReusePatterns [...]/ReusePatterns.jl/src/ReusePatterns.jl:125
[5] forward
@ [...]/ReusePatterns.jl/src/ReusePatterns.jl:122 [inlined]
[6] top-level scope
@ [...]/ReusePatterns.jl/src/ReusePatterns.jl:180
in expression starting at [...]/composition.jl:9
Is something similar supported ?
https://github.com/JeffreySarnoff/TypedDelegation.jl
replaces both
https://github.com/JuliaArbTypes/TypedDelegation.jl (current version is at the above link)
https://github.com/Jeffrey-Sarnoff/Delegate.jl (unmaintained, probably obsolete)
thank you [and nice package]
Hello Giorgio,
Tried the Dataframes example in: ReusePatterns.jl/examples/dataframes.jl
but it does not seem to work in Julia 1.7.0?
Thanks and rregards,
Rafael
I ran into a version of the following minimal example:
using ReusePatterns
@quasiabstract AbstractTest{N, T}
f::NTuple{N, T}
end
@quasiabstract AbstractTest2{N}
f::NTuple{N, Number}
end
@quasiabstract Test <: AbstractTest{2, Number} end
@quasiabstract Test2 <: AbstractTest2{2} end
Then, Test( (1, 1.0) )
produces an error, while Test2( (1, 1.0) )
does not, although they should give the exact same thing. The exact error is
TypeError: in new, expected Tuple{Vararg{T, N}} where {N, T}, got a value of type Tuple{Int64, Float64}
Thanks for this package! tracked down a subtle error/potential bug...
using DataStructures, HDF5, ReusePatterns
mutable struct DsetWrapper
dset::HDF5.Dataset
end
@forward((DsetWrapper,:dset),HDF5.Dataset)
ERROR: LoadError: cannot assign a value to variable DataStructures.list from module Main
When I use ReusePatterns in my own scripts it seems to work fine, but I am unable to use in a package/project.
module TestReuse
using ReusePatterns, HDF5
struct DsetWrapper
dset::HDF5.Dataset
end
@forward((DsetWrapper,:dset),HDF5.Dataset)
end
ERROR: LoadError: Evaluation into the closed module `HDF5` breaks incremental compilation because the side effects will not be permanent. This is likely due to some other module mutating `HDF5` with `eval` during precompilation - don't do this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.