Re: Custom Exponents

2013-12-14 Thread Philippe Sigaud
> > http://dlang.org/phobos/std_math.html#.pow > > See the fourth overload: `if (isFloatingPoint!F && isFloatingPoint!G)`. Is there any difference between using `a ^^ b` and `pow(a,b)`?

Re: How to obtain certain traits of delegates returned by functions in template constraints?

2013-12-14 Thread Philippe Sigaud
I have 3 comments (if you're still reading this thread :) ) First, you could let nextGen determine the return type. Since the template know that nextGen returns an int delegate(int), there is no need for the user to provide the 'int' parameter. So user code could become: void main(string[] argv)

Re: Custom Exponents

2013-12-14 Thread Malkierian
On Sunday, 15 December 2013 at 05:39:03 UTC, Nathan M. Swan wrote: On 12/14/13 8:22 PM, Malkierian wrote: Alright, so I'm trying to do hex string to integer conversion, but I can't for the live of me find how to do exponent calculation in D. Java has a Math.pow() function that allows you to sp

Re: Custom Exponents

2013-12-14 Thread Nathan M. Swan
On 12/14/13 8:22 PM, Malkierian wrote: Alright, so I'm trying to do hex string to integer conversion, but I can't for the live of me find how to do exponent calculation in D. Java has a Math.pow() function that allows you to specify the base and the exponent, but all I've seen in D's libraries a

Re: Custom Exponents

2013-12-14 Thread Ali Çehreli
On 12/14/2013 09:22 PM, Malkierian wrote: Alright, so I'm trying to do hex string to integer conversion, but I can't for the live of me find how to do exponent calculation in D. Java has a Math.pow() function that allows you to specify the base and the exponent, but all I've seen in D's librarie

Re: Custom Exponents

2013-12-14 Thread Malkierian
On Sunday, 15 December 2013 at 05:22:47 UTC, Malkierian wrote: Alright, so I'm trying to do hex string to integer conversion, but I can't for the live of me find how to do exponent calculation in D. Java has a Math.pow() function that allows you to specify the base and the exponent, but all I'

Custom Exponents

2013-12-14 Thread Malkierian
Alright, so I'm trying to do hex string to integer conversion, but I can't for the live of me find how to do exponent calculation in D. Java has a Math.pow() function that allows you to specify the base and the exponent, but all I've seen in D's libraries are functions that allow you to only s

Re: migrating to 64 bit

2013-12-14 Thread Marco Leise
Am Sun, 15 Dec 2013 01:10:18 +0100 schrieb "Stephen Jones" : > I would assume, and please tell me if I am wrong as that is the > point of the post, that any D code will compile on any dmd > compiler irrespective of whether 32 or 64 bit. But I would have > thought the object files compiled would

Re: migrating to 64 bit

2013-12-14 Thread Jesse Phillips
On Sunday, 15 December 2013 at 00:10:20 UTC, Stephen Jones wrote: Also, what is the deal with using dlls from a 32bit system on a 64bit os; is this just backwards compatibility? Any help or helpful links appreciated. 32bit code runs on 64bit platforms (you can thank AMD for that, as Linux do

Re: std.algorithm.splitter improovement?

2013-12-14 Thread Marco Leise
Am Sat, 14 Dec 2013 18:20:13 +0100 schrieb "bearophile" : > Marco Leise: > > > Not at all, the documentation explicitly states: > > > > assert(equal(splitter("hello world", ' '), [ "hello", "", > > "world" ])); > > I didn't see the ' ' in the OP code, sorry. > > A test: > > > void main()

Re: migrating to 64 bit

2013-12-14 Thread Rikki Cattermole
On Sunday, 15 December 2013 at 00:10:20 UTC, Stephen Jones wrote: I have just moved to Windows 8.1 64bit. I copied the dmd compiler and environment I was using on the 32 bit XP and hooked up the environmental variables to see what would happen. When I come to compile and run one of the Derelict

Re: ubyte array changing values between calls? Possible bug?

2013-12-14 Thread Ali Çehreli
On 12/14/2013 10:48 AM, Gary Willoughby wrote: > On Friday, 13 December 2013 at 17:35:27 UTC, John Colvin wrote: >>> public void opAssign(uint value) >>> { >>> this._octets = value.nativeToBigEndian(); >>> assert(this._octets == [1, 2, 3, 4]); >>> } >>> } >> opAssign

migrating to 64 bit

2013-12-14 Thread Stephen Jones
I have just moved to Windows 8.1 64bit. I copied the dmd compiler and environment I was using on the 32 bit XP and hooked up the environmental variables to see what would happen. When I come to compile and run one of the Derelict3 programs it compiles and runs ok (mouse isn't doing what it shou

Re: Interfacing C programs: Pass D string to C function

2013-12-14 Thread Jonathan M Davis
On Friday, December 13, 2013 01:17:41 Jonathan M Davis wrote: > or you could do something like > > auto cstr = str.dup.ptr; Wait. That was stupid of me. Don't do this. It'll give you a char*, but it won't be null-terminated. If you need char*, then use toUTFz!(char*) - though from what Mike's s

Re: const method and return type

2013-12-14 Thread Ali Çehreli
On 12/13/2013 04:30 PM, Adam D. Ruppe wrote: > There's some discussion that auto might strip off the top level > const where it is otherwise allowed, but I'm not sure if that's > actually going to happen or not. Ah. I was about to respond by "that top level const is silly" but I now see that it

Re: const method and return type

2013-12-14 Thread Ali Çehreli
On 12/13/2013 04:24 PM, Andrea Fontana wrote: > Just another thought. If we have: > > class B; > struct C; > > class A > { > void method() const { ... } > B another_class; > C a_struct; > } > > B is just a reference to a object, so method() should not reassign it. > The reference shou

Re: How to obtain certain traits of delegates returned by functions in template constraints?

2013-12-14 Thread DoctorCaptain
Most uses of the 'is expression' allows using a specifier to name the entity that matched. So, inserting ReturnedDelegate in your '== delegate' line gives the name ReturnedDelegate to the delegate. That name can be used further: template exT(T, alias nextGen) if ( // Ensure next

Re: How to obtain certain traits of delegates returned by functions in template constraints?

2013-12-14 Thread Jacob Carlborg
On 2013-12-14 20:53, DoctorCaptain wrote: Second, can I get the level of thoroughness I am going for in these constraints checks with fewer actual checks? As in, is there a more straightforward way to do these checks without sacrificing any of them? Thank you for any and all insight! I would

Re: How to obtain certain traits of delegates returned by functions in template constraints?

2013-12-14 Thread Ali Çehreli
On 12/14/2013 11:53 AM, DoctorCaptain wrote:> My question is hopefully short and straightforward to answer, but it's > also a two-parter. > > I am working on a template that generates a function that implements an > algorithm using several helper functions that are provided to the > template by t

Re: std.algorithm.splitter improovement?

2013-12-14 Thread Dmitry Olshansky
14-Dec-2013 21:20, bearophile пишет: Marco Leise: Not at all, the documentation explicitly states: assert(equal(splitter("hello world", ' '), [ "hello", "", "world" ])); I didn't see the ' ' in the OP code, sorry. A test: void main() { import std.stdio, std.string, std.algorithm;

Re: static if - is the 'static' really needed?

2013-12-14 Thread Parke
On Fri, Dec 13, 2013 at 4:10 AM, comco wrote: > Imagine a world in which a simple 'if' has the semantics of a static if, if > the condition is evaluable at CT. Is this a world you would rather live in? Even so, I would still want static if, so that I would get a compile time error if I mistaken t

How to obtain certain traits of delegates returned by functions in template constraints?

2013-12-14 Thread DoctorCaptain
My question is hopefully short and straightforward to answer, but it's also a two-parter. I am working on a template that generates a function that implements an algorithm using several helper functions that are provided to the template by the user. I would like to add constraints to the temp

Re: ubyte array changing values between calls? Possible bug?

2013-12-14 Thread Gary Willoughby
On Friday, 13 December 2013 at 17:35:27 UTC, John Colvin wrote: On Friday, 13 December 2013 at 16:37:51 UTC, Gary Willoughby wrote: I have the following code which is massively simplified from a larger type. The problem occurs between assigning the value to the type and retrieving it. The val

Re: std.algorithm.splitter improovement?

2013-12-14 Thread bearophile
Marco Leise: Not at all, the documentation explicitly states: assert(equal(splitter("hello world", ' '), [ "hello", "", "world" ])); I didn't see the ' ' in the OP code, sorry. A test: void main() { import std.stdio, std.string, std.algorithm; auto s = "hello world"; s.spl

Re: Ranges: is it ok if front is a data member?

2013-12-14 Thread Marco Leise
Am Sat, 14 Dec 2013 16:38:20 +0100 schrieb "Joseph Rushton Wakeling" : > On Saturday, 14 December 2013 at 15:26:36 UTC, Jakob Ovrum wrote: > > On Friday, 13 December 2013 at 14:52:32 UTC, Marco Leise wrote: > >> Most non-trivial ranges do the actual work in `popFront()' and > >> return a cached va

Re: std.algorithm.splitter improovement?

2013-12-14 Thread Marco Leise
Am Sat, 14 Dec 2013 17:41:22 +0100 schrieb "bearophile" : > seany: > > > for example, splitting "hello world" (two spaces between > > words) will return ["hello" , "", "world"] > > It's a bug. > > Bye, > bearophile Not at all, the documentation explicitly states: assert(equal(splitter("he

Re: updating druntime

2013-12-14 Thread Marco Leise
Am Sat, 14 Dec 2013 08:43:42 +0100 schrieb "Benji" : > On Saturday, 14 December 2013 at 00:15:30 UTC, Marco Leise wrote: > > Am Fri, 13 Dec 2013 21:40:10 +0100 > > schrieb "Benji" : > > > >> I got two errors mentioned above at once.. :( > > > > What the heck is happening on your system? :( > > I

Re: std.algorithm.splitter improovement?

2013-12-14 Thread bearophile
seany: for example, splitting "hello world" (two spaces between words) will return ["hello" , "", "world"] It's a bug. Bye, bearophile

Re: std.algorithm.splitter improovement?

2013-12-14 Thread Peter Alexander
On Saturday, 14 December 2013 at 16:00:06 UTC, seany wrote: the std.algorithm.splitter returns a blank or null (eg a null string "") between two consecuting delimeters. for example, splitting "hello world" (two spaces between words) will return ["hello" , "", "world"] is there an improoved

Re: Performance of ranges verses direct

2013-12-14 Thread Nikolay
And now try -inline-threshold=1024 ;-) Reading -help-hidden sometimes helps. Thanks. It is really game changer. I get my words about ranges back.

std.algorithm.splitter improovement?

2013-12-14 Thread seany
the std.algorithm.splitter returns a blank or null (eg a null string "") between two consecuting delimeters. for example, splitting "hello world" (two spaces between words) will return ["hello" , "", "world"] is there an improoved version of it, which wont return such a blank/null when mult

Re: Ranges: is it ok if front is a data member?

2013-12-14 Thread Joseph Rushton Wakeling
On Saturday, 14 December 2013 at 15:26:36 UTC, Jakob Ovrum wrote: On Friday, 13 December 2013 at 14:52:32 UTC, Marco Leise wrote: Most non-trivial ranges do the actual work in `popFront()' and return a cached value from `front'. It has been argued as a design quirk, that this in general leads to

Re: Ranges: is it ok if front is a data member?

2013-12-14 Thread Jakob Ovrum
On Friday, 13 December 2013 at 14:52:32 UTC, Marco Leise wrote: Am Thu, 12 Dec 2013 08:43:35 -0800 schrieb "H. S. Teoh" : I do this with my own ranges sometimes. Sometimes, it's more performant to precompute the value of .front and store it (as .front), and have .popFront compute the next valu

Re: ubyte array changing values between calls? Possible bug?

2013-12-14 Thread John Colvin
On Friday, 13 December 2013 at 18:01:53 UTC, Rémy Mouëza wrote: It works fine when using dup to the value returned by nativeToBigEndian: public void opAssign(uint value) { this._octets = value.nativeToBigEndian().dup; assert(this._octets == cast (ubyte[]) [1, 2, 3, 4]);