how to compare immutable ints?

2013-06-21 Thread Charles Hixson
How should I compare immutable ints to ensure that they are actually equal? I was quite surprised to receive the following error message: cbt2.d(732): Error: function object.Object.opEquals (Object o) is not callable using argument types (immutable(int)) when I tried to assert that two values

Re: how to compare immutable ints?

2013-06-21 Thread Charles Hixson
On 06/18/2013 12:40 PM, Steven Schveighoffer wrote: On Tue, 18 Jun 2013 15:37:44 -0400, Charles Hixson wrote: (Sorry if this double posts. I'm having trouble getting through at all.) How should I compare immutable ints to ensure that they are actually equal? I was quite surprised to rec

Re: limits for numeric types

2013-06-21 Thread Jesse Phillips
On Friday, 21 June 2013 at 19:30:28 UTC, Craig Dillabaugh wrote: Thank you very much. Now, is there any way to get Google to find my question/your answer if someone searches for "dlang numeric limits"? Cheers, Craig Yes, get the text, "numeric limits" onto the page. Though, "dlang max int" se

Re: help a potential binding author?

2013-06-21 Thread Adam D. Ruppe
I haven't actually used Qt for a while and never used qml but I'll betcha this binding is going to be a pretty difficult task. Simply using it might not be bad, can probably just use a few extern(C) functions to take strings, but expanding it surely will involve talking to complex C++ objects,

help a potential binding author?

2013-06-21 Thread Andrei Alexandrescu
http://stackoverflow.com/questions/17235375/how-to-create-bindings-qml-to-d Andrei

Re: limits for numeric types

2013-06-21 Thread Craig Dillabaugh
On Friday, 21 June 2013 at 21:11:42 UTC, Adam D. Ruppe wrote: On Friday, 21 June 2013 at 19:51:16 UTC, Craig Dillabaugh wrote: I guess I need to ween myself off my Google dependency. Good idea! I became a Bing guy a couple years ago and only go to google for those rare times when the bing res

Re: randomShuffle

2013-06-21 Thread Diggory
On Thursday, 20 June 2013 at 21:48:49 UTC, Joseph Rushton Wakeling wrote: On 06/04/2013 01:03 PM, Diggory wrote: Still a few places to optimise, and I think the compiler optimisation should be able to give a decent speed up as well. Would be interested to see how it compares in your benchmark!

Re: limits for numeric types

2013-06-21 Thread Adam D. Ruppe
On Friday, 21 June 2013 at 19:51:16 UTC, Craig Dillabaugh wrote: I guess I need to ween myself off my Google dependency. Good idea! I became a Bing guy a couple years ago and only go to google for those rare times when the bing results just suck. I find bing to be a much faster website too. (

Re: limits for numeric types

2013-06-21 Thread Ali Çehreli
On 06/21/2013 12:19 PM, Craig Dillabaugh wrote: I feel kind of dumb asking this, as I thought I could solve it with 30 seconds on Google, but no luck. Where can I get values for min/max values for D numeric types, like what is available in limits.h and float.h for C/C++? I have the following

Re: limits for numeric types

2013-06-21 Thread Craig Dillabaugh
On Friday, 21 June 2013 at 19:39:06 UTC, Adam D. Ruppe wrote: On Friday, 21 June 2013 at 19:30:28 UTC, Craig Dillabaugh wrote: Now, is there any way to get Google to find my question/your answer if someone searches for "dlang numeric limits"? Beats me :( Oddly enough, using Bing or Yahoo (sa

Re: limits for numeric types

2013-06-21 Thread H. S. Teoh
On Fri, Jun 21, 2013 at 09:19:36PM +0200, Craig Dillabaugh wrote: > I feel kind of dumb asking this, as I thought I could solve it > with 30 seconds on Google, but no luck. > > Where can I get values for min/max values for D numeric types, > like what is available in limits.h and float.h for C/C++

Re: limits for numeric types

2013-06-21 Thread Adam D. Ruppe
On Friday, 21 June 2013 at 19:30:28 UTC, Craig Dillabaugh wrote: Now, is there any way to get Google to find my question/your answer if someone searches for "dlang numeric limits"? Beats me :(

Re: limits for numeric types

2013-06-21 Thread bearophile
Adam D. Ruppe: etc etc etc. The one that's weird is float.min_normal I think. Don't use float.min/double.min/real.min. I have opened a bug report: http://d.puremagic.com/issues/show_bug.cgi?id=10439 Bye, bearophile

Re: limits for numeric types

2013-06-21 Thread Craig Dillabaugh
On Friday, 21 June 2013 at 19:22:15 UTC, Adam D. Ruppe wrote: On Friday, 21 June 2013 at 19:19:37 UTC, Craig Dillabaugh wrote: Where can I get values for min/max values for D numeric types, like what is available in limits.h and float.h for C/C++? Literally type: int.max int.min long.max long

Re: Is it possible to use global variables spanning modules?

2013-06-21 Thread Adam D. Ruppe
On Friday, 21 June 2013 at 17:47:49 UTC, Gary Willoughby wrote: Do you import the module that declares the __gshared var or import the var itself? Import the module then use the variable. module globals; int a; // or could be __gshared if you don't want it to be thread local module test1

Re: limits for numeric types

2013-06-21 Thread Adam D. Ruppe
On Friday, 21 June 2013 at 19:19:37 UTC, Craig Dillabaugh wrote: Where can I get values for min/max values for D numeric types, like what is available in limits.h and float.h for C/C++? Literally type: int.max int.min long.max long.min etc etc etc. The one that's weird is float.min_normal I t

limits for numeric types

2013-06-21 Thread Craig Dillabaugh
I feel kind of dumb asking this, as I thought I could solve it with 30 seconds on Google, but no luck. Where can I get values for min/max values for D numeric types, like what is available in limits.h and float.h for C/C++? My efforts have demonstrated that using a search engine for D related to

Re: assert(false)

2013-06-21 Thread H. S. Teoh
On Fri, Jun 21, 2013 at 12:36:13AM +0100, Joseph Rushton Wakeling wrote: [...] > private size_t diceImpl(Rng, Range)(ref Rng rng, Range proportions) > if (isForwardRange!Range && isNumeric!(ElementType!Range) && > isForwardRange!Rng) > { > double sum = reduce!("(assert(b >= 0),

Re: Is it possible to use global variables spanning modules?

2013-06-21 Thread Gary Willoughby
On Friday, 21 June 2013 at 16:29:06 UTC, bearophile wrote: Gary Willoughby: is it possible to use global variables spanning modules?< Why don't you use a __gshared module-global var, and then import it in all the modules where you need it? Bye, bearophile I've just been looking at that b

Re: assert(false)

2013-06-21 Thread Ali Çehreli
On 06/21/2013 02:56 AM, Joseph Rushton Wakeling wrote: > I did also have to think about it for a few seconds. You have > a sum of values from an array; you generate a > uniformly-distributed random number point in [0.0, sum); you > sequentially sum values from the same array, and return when > t

Re: Is it possible to use global variables spanning modules?

2013-06-21 Thread bearophile
Gary Willoughby: is it possible to use global variables spanning modules?< Why don't you use a __gshared module-global var, and then import it in all the modules where you need it? Bye, bearophile

Is it possible to use global variables spanning modules?

2013-06-21 Thread Gary Willoughby
Yes i know it's horrible but is it possible to use global variables spanning modules? I need to capture a small amount of program data and deal with it in termination signal handlers. The data will be captured from various classes spread around different modules. I'm thinking the easiest sol

Re: assert(false)

2013-06-21 Thread Steven Schveighoffer
On Thu, 20 Jun 2013 15:48:38 -0400, Joseph Rushton Wakeling wrote: Is it considered good/recommended practice to insert an assert(false) statement in parts of the code that should be unreachable? Or simply an optional choice that may be useful for debugging? I think it's more than good

Re: Tips for fast string concatenation?

2013-06-21 Thread Steven Schveighoffer
On Fri, 21 Jun 2013 06:14:38 -0400, Jonathan M Davis wrote: On Friday, June 21, 2013 12:09:09 Gary Willoughby wrote: Have you any tips for using D when you need fast string concatenation? I regularly use code like this: foreach (i, range) { foo ~= bar; } or: f

alias template parameter

2013-06-21 Thread Sergei Nosov
Hi! I've been thinking about how alias template parameters work and I'm really confused =) It makes perfect sense for literals, names, etc. But what I can't get is how does it work for delegates. If I have a function auto apply(alias fun, T...)(T args) { return fun(args); } And then I

Re: Tips for fast string concatenation?

2013-06-21 Thread Namespace
It's worth pointing out that Appender supports ~= so it's very easy to swap it in, replacing builtin concatenation. This works since 2.062 AFAIK. So is still quite new.

Re: Tips for fast string concatenation?

2013-06-21 Thread John Colvin
On Friday, 21 June 2013 at 11:33:29 UTC, monarch_dodra wrote: On Friday, 21 June 2013 at 10:09:10 UTC, Gary Willoughby wrote: Have you any tips for using D when you need fast string concatenation? I regularly use code like this: foreach (i, range) { foo ~= bar; } or: foo =

Re: Tips for fast string concatenation?

2013-06-21 Thread monarch_dodra
On Friday, 21 June 2013 at 10:09:10 UTC, Gary Willoughby wrote: Have you any tips for using D when you need fast string concatenation? I regularly use code like this: foreach (i, range) { foo ~= bar; } or: foo = foo ~ bar ~ baz ~ qux; I've used std.string.format(...)

Re: Tips for fast string concatenation?

2013-06-21 Thread Jonathan M Davis
On Friday, June 21, 2013 12:09:09 Gary Willoughby wrote: > Have you any tips for using D when you need fast string > concatenation? I regularly use code like this: > > foreach (i, range) > { > foo ~= bar; > } > > or: > > foo = foo ~ bar ~ baz ~ qux; > > I've used st

Re: Tips for fast string concatenation?

2013-06-21 Thread Vladimir Panteleev
On Friday, 21 June 2013 at 10:09:10 UTC, Gary Willoughby wrote: Are there faster ways of appending strings? You'll want to use appender, from std.array: http://dlang.org/phobos/std_array.html#.Appender

Tips for fast string concatenation?

2013-06-21 Thread Gary Willoughby
Have you any tips for using D when you need fast string concatenation? I regularly use code like this: foreach (i, range) { foo ~= bar; } or: foo = foo ~ bar ~ baz ~ qux; I've used std.string.format(...) in some instances which sped things up which surprised me. Are

Re: assert(false)

2013-06-21 Thread Joseph Rushton Wakeling
On 06/21/2013 09:51 AM, monarch_dodra wrote: > Reading that code, it's not immediately obvious to me: The assert makes it > self > documenting. I did also have to think about it for a few seconds. You have a sum of values from an array; you generate a uniformly-distributed random number point in

Re: assert(false)

2013-06-21 Thread monarch_dodra
On Thursday, 20 June 2013 at 23:36:35 UTC, Joseph Rushton Wakeling wrote: On 06/20/2013 11:36 PM, Jonathan M Davis wrote: ... one is necessary as it's in a function that is supposed to return a value. I don't think that that's supposed to be necessary. The only reason that that should happen

phabricator : code review, bug tracking etc

2013-06-21 Thread Timothee Cour
phabricator looks pretty decent for code review, bug tracking etc. It was created at facebook and is used by many other companies; it's actively maintained and developed. It could be a good replacement for bugzilla and other components.