Its always the former. I hadn't thought about using proportions. Is that idea
related to the idea of delta units which I have seen discussed in the Unitful
issue tracker.

> On Feb 18 2016, at 11:29 am, Jeffrey Sarnoff
<[email protected]> wrote:  

>

> In this unit-land, is length always quantity * unit_of_length? or also may
it be proportion * reference_distance (1/4 of the current line length)?

>

> Or -- shall we seek an avenue that somehow is both without being either?  
  
On Wednesday, February 17, 2016 at 5:10:15 PM UTC-5, Jake Rosoman wrote:

>

>> Oops thanks for being patient. By "this" I meant "dispatch on abstract
units/dimensions". The motivation is to be able to write a function which
takes a length without caring what the specific unit of that length is. Be it
feet or cm etc. This is to make the intent of the function clearer and enable
polymorphism. For example:  
  
direction = 0radians  
move(r::Angle) = direction += r  
move(l::Length) = translate(direction, l)  
  
Also speed could be defined as Ratio{d<:size, t<:time}. Which would be
hard to do using unitful as is  

>>

>> On Thu, 18 Feb 2016 at 10:25 AM Jeffrey Sarnoff
<[email protected]> wrote:  

>>

>>> Jake,

>>>

>>>  

>>>

>>> It would be helpful to know more clearly what is the "this" that you are
experimenting with "ways to achieve this"?  
>>>

>>> I took a glance at your code, and one thing that is happening is you have
left some low-hanging abstraction on the table.  That constrains Julia's
ability to simplify through organized multidispatch.  I will give it more than
a glance overnight -- pretend it all works perfectly, show me what you want to
do with it then.

>>>

>>>  
>>>

>>>  

>>>

>>> On Wednesday, February 17, 2016 at 3:59:15 PM UTC-5, Jake Rosoman wrote:

>>>

>>>> Oh yup I thought that was the case but wanted to check.  
  
I've started experimenting with ways to achieve this but I am getting massive
amounts of code generated compared to Unitful. I just uploaded uploaded my
work so far at
[https://GitHub.com/jkroso/units.jl](https://GitHub.com/jkroso/units.jl). If
anyone could help explain the difference in code gen that would be great and
I'll try contribute back to Unitful  

>>>

>>>> On Thu, 18 Feb 2016 at 7:02 AM Andrew Keller
<[email protected]> wrote:  

>>>>

>>>>> Hi Jake,

>>>>>

>>>>>  

>>>>>

>>>>> I agree with Jeffrey's response mostly, but want to clarify that Unitful
is not strictly focused on the SI system. You'll see that you can use units of
acre-feet, very much not an SI unit, which could be useful if you happen to
manage a water reservoir in the United States, I guess.

>>>>>

>>>>>  

>>>>>

>>>>> If you were instead asking whether or not you could write methods that
dispatch on the dimensions of a unit, the current answer is no, although maybe
that could change eventually.

>>>>>

>>>>>  

>>>>>

>>>>> Best,

>>>>>

>>>>> Andrew

>>>>>

>>>>>  

>>>>>

>>>>> On Wednesday, February 17, 2016 at 3:25:37 AM UTC-8, Jeffrey Sarnoff
wrote:

>>>>>

>>>>>> Jake,

>>>>>>

>>>>>>  

>>>>>>

>>>>>> Julia's type system is well suited to do just that.  Unitful is focused
on units in SI system, things like Meters, Kilograms and Joules.

>>>>>>

>>>>>>  

>>>>>>

>>>>>> One approach to abstract units like size, where size may be relative to
the number of pixels on a screen or the width of a page,

>>>>>>

>>>>>> is define your own type, a kind of size relative to something.  In your
example, s is not a unit of measure (strictly speaking);

>>>>>>

>>>>>> s is a quantity interpreted in terms of some absolute or relative unit
of measure -- 5 pixels, 1/4 page.  Because pixels and pages

>>>>>>

>>>>>> are not always the same number of, say, millimeters, using SI units for
that abstraction likely is not what you want.

>>>>>>

>>>>>>  

>>>>>>

>>>>>> If you want more guidance, please give some more context.

>>>>>>

>>>>>>  

>>>>>>

>>>>>> On Wednesday, February 17, 2016 at 4:43:13 AM UTC-5, Jake Rosoman
wrote:

>>>>>>

>>>>>>> Is it possible to talk about abstract types of units like size. e.g
`drawline(s::Size) = ...`?  
  
On Saturday, February 13, 2016 at 9:23:22 AM UTC+13, Andrew Keller wrote:

>>>>>>>

>>>>>>>> I'm happy to share a package I wrote for using physical units in
Julia, [Unitful.jl](https://www.github.com/ajkeller34/Unitful.jl). Much credit
and gratitude is due to Keno Fischer for the
[SIUnits.jl](https://www.github.com/keno/SIUnits.jl) package which served as
my inspiration. This is a work in progress, but I think perhaps a serviceable
one depending on what you're doing.

>>>>>>>>

>>>>>>>>  

>>>>>>>>

>>>>>>>> Like SIUnits.jl, this package encodes units in the type signature to
avoid run-time performance penalties. From there, the implementations diverge.
The package is targeted to Julia 0.5 / master, as there are some limitations
with how promote_op is used in Julia 0.4
[(#13803)](https://github.com/JuliaLang/julia/pull/13803). I decided it wasn't
worth targeting 0.4 if the behavior would be inconsistent.

>>>>>>>>

>>>>>>>>  

>>>>>>>>

>>>>>>>> Some highlights include:

>>>>>>>>

>>>>>>>>   * Non-SI units are treated on the same footing as SI units, with
only a few exceptions (unit conversion method). Use whatever weird units you
want.

>>>>>>>>   * Support for units like micron / (meter Kelvin), where some of the
units could cancel out but you don't necessarily want them to.  

>>>>>>>>   * Support for LinSpace and other Range types. Probably there are
still some glitches to be found, though.  

>>>>>>>>   * Support for rational exponents of units.

>>>>>>>>   * Some tests (see these for usage examples).

>>>>>>>>

>>>>>>>> Please see the documentation for a comprehensive discussion,
including issues / to do list, as well as how to add your own units, etc.

>>>>>>>>

>>>>>>>> Comments and feedback are welcome.  

>>>>>>>>

>>>>>>>>  

>>>>>>>>

>>>>>>>> Best,  

>>>>>>>>

>>>>>>>> Andrew Keller

Reply via email to