www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6715] New: Using a custom pow function for ^^

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6715

           Summary: Using a custom pow function for ^^
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: siegelords_abode yahoo.com



I want to use a custom pow function (e.g. the one from the C standard library,
or from Tango) instead of the one in std.math, but a^^b is rewritten into
std.math.pow(a, b) which makes this difficult to accomplish. I can work around
it by using a static method like so:

struct std
{
    struct math
    {
        static auto pow(real a, real b);
    }
}

But I'd rather not have to do that (it breaks std imports, for example). Can we
have ^^ rewritten into a simple pow?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 22 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6715


siegelords_abode yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|Other                       |All
         OS/Version|Linux                       |All



An even better idea occurred to me today, now that UFCS has been introduced.
Instead of my original proposal, why not do this:

a^^b

turns into

a.pow(b)

Due to the way properties are looked up this is safer than the original
proposal (bad things won't happen if you have variables named 'pow' for
example).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6715


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc





 Can we have ^^ rewritten into a simple pow?
Note: I think that currently a^^b is optimized in some special cases by the compiler (like b = 2). A simple function call causes a loss of those handy optimizations. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 04 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6715






 
 Can we have ^^ rewritten into a simple pow?
Note: I think that currently a^^b is optimized in some special cases by the compiler (like b = 2). A simple function call causes a loss of those handy optimizations.
I never asked for those optimizations to be disabled. I am solely talking about the cases when ^^ is rewritten as a function. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 29 2012