Giter VIP home page Giter VIP logo

Comments (6)

sostock avatar sostock commented on June 28, 2024

I don’t see the point of extending the @eqrelation macro like this. The main advantage of the macro is that it defines the methods for conversion in both directions, i.e., you need to write one macro call and get two edconvert methods. With the proposed @eqrelation Name a = f(b), one has to use the macro twice to get both directions and one has to define the function f and its inverse. This is no easier than just writing these functions as edconvert methods.

Regarding the Plato–sg conversion, I still don’t think that an equivalence is the correct thing. But I agree that using different dimensions is also ugly. I would prefer a different solution:

The thing about Plato is that it’s not proportional to other units of its dimension. Therefore, it is like an AffineUnits, only more complicated. One could define a new type of unit (maybe QuadraticUnits) that is related to another unit by a quadratic relation (instead of just an offset, like for AffineUnits) and define Plato as such a unit. Then one would just use uconvert without Equivalences (since those are for converting between quantities of different dimensions).

from unitfulequivalences.jl.

rmsrosa avatar rmsrosa commented on June 28, 2024

Fine. I just thought it would be more elegant to have a more consistent way of defining the equivalences, regardless of the form, and it would make it slightly easier for users of the package, which is the aim of any package. Besides, it wouldn't change the current use of the proportional and anti-proportional equivalences. But that's ok, no big deal.

from unitfulequivalences.jl.

sostock avatar sostock commented on June 28, 2024

Thanks for your input. I’m also in favor of consistency and ease of use, but I don’t think the extended @eqrelation macro would achieve that:

  • I don’t think it is consistent that some forms of the macro define the conversion in both directions and some only in one direction.
  • I don’t think it is easier because one still has to define the function, so one might as well define it as a edconvert method. Of course, this has to be properly documented (which I plan to do soon).

from unitfulequivalences.jl.

rmsrosa avatar rmsrosa commented on June 28, 2024

Well, we could write @eqrelation y = e * x and @eqrelation y = e / x and have the code figure out whether rhs.args has length 3 or 2, to distinguish from @eqrelation y = f(x), and proceed accordingly.

But that is ok. I am just thinking out loud. I understand if using macro just as an alias is considered not good coding. I don't know. I am here to learn. And I am! I have never even browsed over this meta-programming stuff, and it is being fun to learn it, at least. I don't know how else I could help, though.

from unitfulequivalences.jl.

rmsrosa avatar rmsrosa commented on June 28, 2024

I don't know whether you are considering this or not, but for the moment I am okay with using edconvert directly, so I feel I should close the issue since I was the one to raise it.

from unitfulequivalences.jl.

sostock avatar sostock commented on June 28, 2024

I’m not really considering this, since I think it is not much easier than defining edconvert methods.

from unitfulequivalences.jl.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.