delegate object instead of a literal

2011-08-14 Thread Joel Christensen
Hi, This program loops through a string until it finds a number and gives the position of it. The first assert works, but not the second one. import std.algorithm; void main() { static bool isNumber( char input, char dummy ) { if ( ( input >= '0' && input <= '9' ) ||

Re: delegate object instead of a literal

2011-08-14 Thread Jonathan M Davis
On Sunday, August 14, 2011 20:50:03 Joel Christensen wrote: > Hi, > > This program loops through a string until it finds a number and gives > the position of it. > > The first assert works, but not the second one. > > import std.algorithm; > > void main() { > static bool isNumber( char in

Re: delegate object instead of a literal

2011-08-14 Thread Jonathan M Davis
On Sunday, August 14, 2011 03:23:39 Jonathan M Davis wrote: > On Sunday, August 14, 2011 20:50:03 Joel Christensen wrote: > > Hi, > > > > This program loops through a string until it finds a number and gives > > the position of it. > > > > The first assert works, but not the second one. > > > >

Re: delegate object instead of a literal

2011-08-14 Thread Jonathan M Davis
On Sunday, August 14, 2011 03:23:39 Jonathan M Davis wrote: > On Sunday, August 14, 2011 20:50:03 Joel Christensen wrote: > > Hi, > > > > This program loops through a string until it finds a number and gives > > the position of it. > > > > The first assert works, but not the second one. > > > >

D with gmp via swig

2011-08-14 Thread Oliver
Hello I am trying to get to a gmp interface for D2. I have some trouble to get that to work, however. Perhaps someone has an idea what I am doing wrong. I must admit I am not sure this is a D issue or a swig issue or something else. The interface file for swig cat gmpd.i %module gmpd %{ #include

Re: D with gmp via swig

2011-08-14 Thread Iain Buclaw
== Quote from Oliver (oliver.ruebenkoe...@web.de)'s article > Hello I am trying to get to a gmp interface for D2. I have some trouble to get > that to work, however. Perhaps someone has an idea what I am doing wrong. I > must admit I am not sure this is a D issue or a swig issue or something else.

Re: D with gmp via swig

2011-08-14 Thread Oliver
Thanks Iain, I'll contact the swig team about it. Oliver

Re: D with gmp via swig

2011-08-14 Thread David Nadlinger
On 8/14/11 1:29 PM, Oliver wrote: Hello I am trying to get to a gmp interface for D2. I have some trouble to get that to work, however. Perhaps someone has an idea what I am doing wrong. I must admit I am not sure this is a D issue or a swig issue or something else. […] /opt/usr/local/bin/gdc

Re: D with gmp via swig

2011-08-14 Thread Caligo
Shouldn't there be an interface to GMP and MPFR in Phobos by default?

Re: D with gmp via swig

2011-08-14 Thread Oliver
Thanks David, so when I gcc -fPIC -c gmpd_wrap.c gcc -shared -Wl,-soname,libgmpd_wrap.so.1 -o libgmpd_wrap.so.1.0.1 gmpd_wrap.o -lgmp ln -s libgmpd_wrap.so.1.0.1 libgmpd_wrap.so /opt/usr/local/bin/gdc main.d gmpd.d gmpd_im.d -I. -L. -lgmpd_wrap I get the /usr/bin/ld: __gmpn_ior_n: TLS definit

Re: D with gmp via swig

2011-08-14 Thread David Nadlinger
On 8/14/11 2:34 PM, Oliver wrote: /opt/usr/local/bin/gdc main.d gmpd.d gmpd_im.d -I. -L. -lgmpd_wrap You don't need to link the .so in (although I'm surprised to see that it produces linker errors, I didn't remember that there are name collisions with the default settings), it will be loaded

Re: D with gmp via swig

2011-08-14 Thread Oliver
== Quote from David Nadlinger (s...@klickverbot.at)'s article > On 8/14/11 2:34 PM, Oliver wrote: > > /opt/usr/local/bin/gdc main.d gmpd.d gmpd_im.d -I. -L. -lgmpd_wrap > You don't need to link the .so in (although I'm surprised to see that it > produces linker errors, I didn't remember that there

Re: D with gmp via swig

2011-08-14 Thread David Nadlinger
On 8/14/11 3:03 PM, Oliver wrote: I did have to copy the libgmpd_wrap* to some place were the linker could find it, of course. Alternatively, you could set LD_LIBRARY_PATH to where your library resides. If there is demand, I could definitely look into adding static linking support to SWIG (i

Re: D with gmp via swig

2011-08-14 Thread Oliver
== Quote from David Nadlinger (s...@klickverbot.at)'s article > On 8/14/11 3:03 PM, Oliver wrote: > > I did have to copy the libgmpd_wrap* to some place were the linker could > > find it, > > of course. > Alternatively, you could set LD_LIBRARY_PATH to where your library > resides. If there is dem

Exception: constructor arguments?

2011-08-14 Thread mimocrocodil
Where I can find description of Exception class? I seen this URLs, but they do not contain this information: http://www.d-programming-language.org/phobos/std_exception.html http://www.d-programming-language.org/phobos/core_exception.html http://www.d-programming-language.org/errors.html

Re: Exception: constructor arguments?

2011-08-14 Thread Johannes Pfau
mimocrocodil wrote: >Where I can find description of Exception class? > >I seen this URLs, but they do not contain this information: > >http://www.d-programming-language.org/phobos/std_exception.html >http://www.d-programming-language.org/phobos/core_exception.html >http://www.d-programming-languag

Re: D with gmp via swig

2011-08-14 Thread Andrej Mitrovic
This seems ancient, but maybe it could help: http://www.dsource.org/projects/bindings/browser/trunk/gmp

Re: Exception: constructor arguments?

2011-08-14 Thread mimocrocodil
Johannes Pfau: thanks! Next question: Why do we always have to send a text message with a standard class of Exception? After all, it might be never used, for example due to the fact that error messages are not sent to the user "as is": exception can be analyzed and translated for international

Re: Exception: constructor arguments?

2011-08-14 Thread Jonathan M Davis
On Sunday, August 14, 2011 15:48:36 mimocrocodil wrote: > Johannes Pfau: thanks! > > Next question: > > Why do we always have to send a text message with a standard class of > Exception? > > After all, it might be never used, for example due to the fact that error > messages are not sent to the

Re: enum inheritance?

2011-08-14 Thread Ary Manzana
On 8/13/11 9:42 PM, Simen Kjaeraas wrote: On Sun, 14 Aug 2011 01:15:29 +0200, mimocrocodil <4deni...@gmail.com> wrote: Hi! I am want to extend available enum to provide more items to them. How I can do this job without manual copying of exsisting enum items? If what you want is a new enum t

Re: Weird timing issue with Thread.sleep

2011-08-14 Thread Marco Leise
Am 03.08.2011, 19:21 Uhr, schrieb Steven Schveighoffer : On Wed, 03 Aug 2011 13:14:50 -0400, Andrej Mitrovic wrote: Take a look at this: import std.stdio; import core.thread; void main() { foreach (x; 0 .. 1000) { Thread.sleep(dur!("usecs")(999)); writeln(x);

Re: This seems like what could be a common cause of bugs

2011-08-14 Thread Marco Leise
Am 09.07.2011, 00:45 Uhr, schrieb Andrej Mitrovic : This is just an observation, not a question or anything. void main() { enum width = 100; double step = 1 / width; writeln(step); // 0 } I've just had this bug in my code. I forgot to make either width or 1 a floating-point typ

Split by length?

2011-08-14 Thread Andrej Mitrovic
Is there something in Phobos with which I could do: auto arr = [1, 2, 3, 4, 5, 6]; int[][] newarr = arr.splitLength(2); assert(newarr.length == 3); ?

Re: delegate object instead of a literal

2011-08-14 Thread Jonathan M Davis
On Sunday, August 14, 2011 20:50:03 Joel Christensen wrote: > Hi, > > This program loops through a string until it finds a number and gives > the position of it. > > The first assert works, but not the second one. > > import std.algorithm; > > void main() { > static bool isNumber( char in

Re: Split by length?

2011-08-14 Thread Andrej Mitrovic
Simplified (and slow) implementation: T[] splitLength(T)(T arr, size_t count) if (isArray!T) { T[] result; while (arr.length) { result ~= arr.take(count); arr.popFrontN(count); } return result; }

Re: Split by length?

2011-08-14 Thread Andrej Mitrovic
Strings are an exception again, that code won't work for strings. Damn..

Re: Split by length?

2011-08-14 Thread Jonathan M Davis
On Monday, August 15, 2011 04:49:59 Andrej Mitrovic wrote: > Is there something in Phobos with which I could do: > > auto arr = [1, 2, 3, 4, 5, 6]; > > int[][] newarr = arr.splitLength(2); > assert(newarr.length == 3); I could have sworn that there was a function that did this, but I can't find

Re: delegate object instead of a literal

2011-08-14 Thread Joel Christensen
On 14-Aug-11 10:44 PM, Jonathan M Davis wrote: On Sunday, August 14, 2011 03:23:39 Jonathan M Davis wrote: On Sunday, August 14, 2011 20:50:03 Joel Christensen wrote: Hi, This program loops through a string until it finds a number and gives the position of it. The first assert works, but not

Re: delegate object instead of a literal

2011-08-14 Thread Joel Christensen
On 15-Aug-11 2:55 PM, Jonathan M Davis wrote: On Sunday, August 14, 2011 20:50:03 Joel Christensen wrote: Hi, This program loops through a string until it finds a number and gives the position of it. The first assert works, but not the second one. import std.algorithm; void main() {

Re: delegate object instead of a literal

2011-08-14 Thread Joel Christensen
On 15-Aug-11 5:21 PM, Joel Christensen wrote: On 15-Aug-11 2:55 PM, Jonathan M Davis wrote: On Sunday, August 14, 2011 20:50:03 Joel Christensen wrote: Hi, This program loops through a string until it finds a number and gives the position of it. The first assert works, but not the second one.