March 09, 2005
Would have saved me at least 1 minute thinking about the alternatives (and another two writing my post)...

Actually, I think I can summarize my position on this something like this:

All the instructions of modern CPU's should be accessible from the core languages, without the need for libraries.

OK, I can see the problems with this statement, MMX, SSE, etc.. Well maybe vector operations should imply the usage of these? And then there's inline assembly and I can just as well code my own 'fpow' without the need of a library.

Like I said, not so important.

L.

"Martin M. Pedersen" <martin@moeller-pedersen.dk> wrote in message news:d0n9dr$2m6e$1@digitaldaemon.com...
> "Lionello Lunesu" <lio@lunesu.removethis.com> skrev i en meddelelse news:d0n7nn$2kc7$1@digitaldaemon.com...
>>I KNEW I'd get at least one such response :-) And yeah, you're right.
>> In fact, I got the ** idea when I was defining some constant, 1024*1024, and thought 'it would be nice to do 1024**2' and then thought 'I should simply write 1048576' closely followed by the though 'I should write 2<<20'..
>
> Now I see why '**' would have some value to you :-)
>
> Regards,
> Martin
>
> 


March 09, 2005
In article <d0nl50$2sl$1@digitaldaemon.com>, Lionello Lunesu says...
>
>(nothing)**(pointer) would mean a double dereference, but (identifier)**(identifier) can't possibly be anything else than 'to the power' ? Or doesn't the parsing work this way? Probably not context-free this way, right?
>
>L.
>

Still looks a touch confusing IMO.  Why not use ^^ and be done with it?

> const uint MEGABYTE = 1024^^2;

I don't forsee it being at all confusing since the xor operator (^) seems to only get special use anyway.  Plus there is no valid grammar that reads like this already, so its context free and compiler friendly to add.

I'd also like to propose the signature of 'opPower()' for overloading as well.

- EricAnderton at yahoo
March 10, 2005
Lionello Lunesu schrieb:
> How about adding an operator ** for 'to the power' ?

Nice idea. (Thought about it myself, but never took the trouble of bringing it up...)

> I know there's no single CPU instruction to do 'x to the power n' with integers (only floats, right?) but it seems silly that you need a library function to be able to do 'to the power'.
> 
> Maybe 'x**n' should simply always return a float?

Definitely not. It should behave similar to '/': Dividing two integers results in an integer even if mathematically, it should result in a fraction.

This should also upscale to float vs. complex: if you do (-1.0)**0.5, it should raise some exception. Only (-1.0+0.0i)**0.5 should return an imaginary value.

> Definately not important, I know.

But also not a big issue to include.
1 2 3
Next ›   Last »