Skip to content

tehrengruber/ExtendedParametricTypes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExtendedParametricTypes

This module allows deferring the calculation of field types until type parameters are known (see JuliaLang/julia#18466).

Example

using ExtendedParametricTypes

# must be called once in every module it is being used in
ExtendedParametricTypes.@Initialize

@EPT type Bla{A}
  field::eltype(A)
end

obj = @EPT(Bla{Array{Int, 1}})(3)

# evaluates to true
fieldtype(@EPT(Bla{Array{Int, 1}}), :field) == Int

# return type of this anonymous function is inferred correctly to Int
dummy = () -> @EPT(Bla{Array{Int, 1}})(1).field
assert(first(Base.return_types(dummy)) == Int)

Prototype. Expect things to break.

TODO

  • Dispatch on EPTs does not work as one would expect
  • Add some error handling
  • Docstrings for generated types

About

This module allows deferring the calculation of field types until type parameters are known (see https://github.com/JuliaLang/julia/issues/18466).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages