>  My thinking being that this would help avoid ambiguity with my code, as I 
> sometimes work with other units of time (e.g. seconds) that are also 
> floating point numbers. Of course, this introduced a number of problems in 
> my existing code, including

There is also the Units.jl package, which may be of use?

>    1. Arithmetic operators not defined for type JDate. My workaround for 
>    this has thus far been to overload the operators to accept JDate types.
>    2. My functions not having methods that accept time as a JDate type. My 
>    workaround for this has been to change the function to accept 
> time::FloatingPoint 
>    instead of time::Float64, but this workaround does not work for Arrays.

This is a only partially solved problem, as far as I know.  How do I
wrap a datatype without having to re-implement all its methods.
Sometimes this can be done through subtyping, but not always.

One approach is to use a macro to delegate methods to one of the fields
of the datatype:
https://github.com/JuliaLang/DataStructures.jl/search?utf8=%E2%9C%93&q=delegate
https://github.com/JuliaLang/julia/pull/3292

For relatively simple number types, as in your case here, it might be
better to manually hook into the "conversion and promotion" framework of
Julia:
http://docs.julialang.org/en/latest/manual/conversion-and-promotion/

Reply via email to