Checking if a string contains a string?

2013-10-17 Thread Jeremy DeHaan
Maybe I am just tired or something, but I tried searching for a way that is already included in phobos for checking if a string contains another string and couldn't find anything. I managed to write my own function for doing this, but I figured I would ask in case I am crazy and just missed a

Re: Checking if a string contains a string?

2013-10-17 Thread evilrat
On Thursday, 17 October 2013 at 06:27:19 UTC, Jeremy DeHaan wrote: Maybe I am just tired or something, but I tried searching for a way that is already included in phobos for checking if a string contains another string and couldn't find anything. I managed to write my own function for doing

Re: Checking if a string contains a string?

2013-10-17 Thread Ali Çehreli
On 10/16/2013 11:27 PM, Jeremy DeHaan wrote: Maybe I am just tired or something, but I tried searching for a way that is already included in phobos for checking if a string contains another string and couldn't find anything. I managed to write my own function for doing this, but I figured I

Re: mutable, const, immutable guidelines

2013-10-17 Thread qznc
On Wednesday, 16 October 2013 at 20:33:23 UTC, H. S. Teoh wrote: I'm of the view that code should only require the minimum of assumptions it needs to actually work. If your code can work with mutable types, then let it take a mutable (unqualified) type. If your code works without modifying

Re: mutable, const, immutable guidelines

2013-10-17 Thread qznc
On Wednesday, 16 October 2013 at 20:33:23 UTC, H. S. Teoh wrote: I'm of the view that code should only require the minimum of assumptions it needs to actually work. If your code can work with mutable types, then let it take a mutable (unqualified) type. If your code works without modifying

Re: Interfacing via Java Native Interface

2013-10-17 Thread Andrew
Concluding, I can post the could if you like, or I can first try compiling it for ARM :-) This might help :- http://forum.dlang.org/post/dpzvxpncqabzxebgd...@forum.dlang.org

Re: cannot call impure function ~this

2013-10-17 Thread Kenji Hara
On Wednesday, 16 October 2013 at 07:58:09 UTC, Namespace wrote: On Wednesday, 16 October 2013 at 07:32:27 UTC, monarch_dodra wrote: On Wednesday, 16 October 2013 at 07:27:25 UTC, Namespace wrote: On Wednesday, 16 October 2013 at 07:23:45 UTC, monarch_dodra wrote: On Tuesday, 15 October 2013

Re: cannot call impure function ~this

2013-10-17 Thread Namespace
In this case, the created struct literal A() will be moved out to the function getA(). So dtor is not called and compiler should not cause cannot call impure function error. I filed a bug report and posted possible compiler fix. http://d.puremagic.com/issues/show_bug.cgi?id=11286

Re: Checking if a string contains a string?

2013-10-17 Thread Jonathan M Davis
On Thursday, October 17, 2013 08:27:17 Jeremy DeHaan wrote: Maybe I am just tired or something, but I tried searching for a way that is already included in phobos for checking if a string contains another string and couldn't find anything. I managed to write my own function for doing this, but

Re: Questions about VisualD

2013-10-17 Thread Namespace
On Wednesday, 16 October 2013 at 22:18:57 UTC, Namespace wrote: I've clicked on Build Phobos browse info and now I have absolute no idea how I can restore my old class view for my current project. Any suggestions? And it seems that VisualD ignores all of my Tasks. My Tasklist is always empty,

how would D be different if string were const(char)[]?

2013-10-17 Thread Daniel Davidson
If it would be no different then why prefer immutable(char)[] for string?

Re: how would D be different if string were const(char)[]?

2013-10-17 Thread Dicebot
On Thursday, 17 October 2013 at 13:08:18 UTC, Daniel Davidson wrote: If it would be no different then why prefer immutable(char)[] for string? Allocation-free slicing would have been illegal/unsafe then as someone could have possibly modified underlying chars via mutable reference.

Re: how would D be different if string were const(char)[]?

2013-10-17 Thread Dicebot
Small example, this is valid D: void main() { char[] mut = aaa.dup; const(char)[] str = mut; mut[1] = 'b'; assert (str == aaa); // oops }

Re: mutable, const, immutable guidelines

2013-10-17 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 20:33:23 UTC, H. S. Teoh wrote: On Wed, Oct 16, 2013 at 09:45:09PM +0200, Daniel Davidson wrote: On Wednesday, 16 October 2013 at 19:12:48 UTC, Dicebot wrote: [...] I think any usage of immutable with types/entities not initially designed for immutability is

Spawning a pty in D

2013-10-17 Thread Colin Grogan
Im having an issue I can link to the C header file pty.h (http://man7.org/linux/man-pages/man3/openpty.3.html) and call forkpty like here: http://dpaste.dzfl.pl/c3b07855 You have to compile that by linking with the util library ( add libs-posix: [util] to dubs package.json ) For ease of

Re: Spawning a pty in D

2013-10-17 Thread Adam D. Ruppe
On Thursday, 17 October 2013 at 13:53:39 UTC, Colin Grogan wrote: Anyone have any experience with this? I actually have been writing a terminal emulator for the last few weeks https://github.com/adamdruppe/terminal-emulator But for reading and writing from the pty, I just used the unix

Re: how would D be different if string were const(char)[]?

2013-10-17 Thread Jonathan M Davis
On Thursday, October 17, 2013 15:18:19 Dicebot wrote: On Thursday, 17 October 2013 at 13:08:18 UTC, Daniel Davidson wrote: If it would be no different then why prefer immutable(char)[] for string? Allocation-free slicing would have been illegal/unsafe then as someone could have

Re: how would D be different if string were const(char)[]?

2013-10-17 Thread Dicebot
Well, yeah. it is memory safe but you can't slice a string and be sure its value won't change silently - comparable semantical safety disaster IMHO.

Re: how would D be different if string were const(char)[]?

2013-10-17 Thread Jonathan M Davis
On Thursday, October 17, 2013 18:50:25 Dicebot wrote: Well, yeah. it is memory safe but you can't slice a string and be sure its value won't change silently - comparable semantical safety disaster IMHO. Yeah. You have to be concerned about whether the values change, which makes the string

Re: Questions about VisualD

2013-10-17 Thread Rainer Schuetze
On 17.10.2013 00:18, Namespace wrote: I've clicked on Build Phobos browse info and now I have absolute no idea how I can restore my old class view for my current project. Any suggestions? You want to remove the phobos info from the class view? You'll have to delete the generated json files

Re: how would D be different if string were const(char)[]?

2013-10-17 Thread Meta
On Thursday, 17 October 2013 at 13:08:18 UTC, Daniel Davidson wrote: If it would be no different then why prefer immutable(char)[] for string? Strings are immutable in quite a few other languages. Ex: Java, Python. I found this old article written by Walter:

Re: Questions about VisualD

2013-10-17 Thread Namespace
On Thursday, 17 October 2013 at 18:18:39 UTC, Rainer Schuetze wrote: On 17.10.2013 00:18, Namespace wrote: I've clicked on Build Phobos browse info and now I have absolute no idea how I can restore my old class view for my current project. Any suggestions? You want to remove the phobos

Re: how would D be different if string were const(char)[]?

2013-10-17 Thread Daniel Davidson
On Thursday, 17 October 2013 at 18:28:31 UTC, Meta wrote: On Thursday, 17 October 2013 at 13:08:18 UTC, Daniel Davidson wrote: If it would be no different then why prefer immutable(char)[] for string? Strings are immutable in quite a few other languages. Ex: Java, Python. I found this old

Re: how would D be different if string were const(char)[]?

2013-10-17 Thread Jonathan M Davis
On Thursday, October 17, 2013 21:17:37 Daniel Davidson wrote: Strings/slices have sharing. Can the same issue/benefit occur with primitives? Would you ever have a need for `immutable(int)` over `const(int)`? For value types, there's no real difference between immutable and const. Because

matrix business in D

2013-10-17 Thread Yura
Dear D programmers, I am very new to D programming language. I just started to learn it as an alternative to python since the latter sometimes is too slow. My question is whether there some simple ways to solve linear algebra problems in D programming language? E.g. matrix multiplication,

What version of the DMD front end is this GDC using?

2013-10-17 Thread Spacen Jasset
Hello, Which version of the DMD front end is this gdc release using? jason@adrastea:~$ gdc -v Using built-in specs. COLLECT_GCC=gdc COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper Target: i686-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro

Re: Questions about VisualD

2013-10-17 Thread Namespace
On Thursday, 17 October 2013 at 18:18:39 UTC, Rainer Schuetze wrote: On 17.10.2013 00:18, Namespace wrote: I've clicked on Build Phobos browse info and now I have absolute no idea how I can restore my old class view for my current project. Any suggestions? You want to remove the phobos

Re: Function pointer to member function.

2013-10-17 Thread TheFlyingFiddle
On Thursday, 17 October 2013 at 03:21:38 UTC, Chris Cain wrote: On Thursday, 17 October 2013 at 01:17:21 UTC, TheFlyingFiddle wrote: I would like to get access to a member function pointer. Taking the this* as the first argument. ...snip... How should i implement getFP above? Is it even

Re: Questions about VisualD

2013-10-17 Thread Rainer Schuetze
On 17.10.2013 20:44, Namespace wrote: And it seems that VisualD ignores all of my Tasks. My Tasklist is always empty, whats wrong? Or is this not implemented? The Tasklist is not implemented. That is a real minus. :/ Any chance that this comes with the next release? Probably not in the

Re: matrix business in D

2013-10-17 Thread Ali Çehreli
On 10/17/2013 01:31 PM, Yura wrote: Dear D programmers, I am very new to D programming language. I just started to learn it as an alternative to python since the latter sometimes is too slow. My question is whether there some simple ways to solve linear algebra problems in D programming

Re: Starting D with a project in mind.

2013-10-17 Thread Andrew
Does anybody know if this is now fixed ? :- https://bitbucket.org/goshawk/gdc/issue/120/fsection-anchors-broken-on-arm I might be wrong but I could be facing this bug when trying to run any of the vibe.d samples, here's an example :- (gdb) cont Continuing. Program received signal SIGSEGV,

Re: What version of the DMD front end is this GDC using?

2013-10-17 Thread H. S. Teoh
On Thu, Oct 17, 2013 at 09:52:17PM +0100, Spacen Jasset wrote: Hello, Which version of the DMD front end is this gdc release using? You can find out with this code: pragma(msg, __VERSION__); jason@adrastea:~$ gdc -v Using built-in specs. COLLECT_GCC=gdc

Re: how would D be different if string were const(char)[]?

2013-10-17 Thread Dicebot
On Thursday, 17 October 2013 at 19:53:34 UTC, Jonathan M Davis wrote: For value types, there's no real difference between immutable and const. Because they're value types, you can't have mutable references to them. The differences between const and immutable only really come into play once

Re: how would D be different if string were const(char)[]?

2013-10-17 Thread Meta
On Thursday, 17 October 2013 at 19:17:38 UTC, Daniel Davidson wrote: True and I believe they do it without an immutable keyword. They do, but it's a special case, as opposed to D. I'm not questioning the value of a non-mutable type, just trying to get to the heart of why the keyword

Re: mutable, const, immutable guidelines

2013-10-17 Thread H. S. Teoh
On Thu, Oct 17, 2013 at 08:56:08AM +0200, qznc wrote: On Wednesday, 16 October 2013 at 20:33:23 UTC, H. S. Teoh wrote: I'm of the view that code should only require the minimum of assumptions it needs to actually work. If your code can work with mutable types, then let it take a mutable

Re: mutable, const, immutable guidelines

2013-10-17 Thread H. S. Teoh
On Thu, Oct 17, 2013 at 09:08:16AM +0200, qznc wrote: On Wednesday, 16 October 2013 at 20:33:23 UTC, H. S. Teoh wrote: I'm of the view that code should only require the minimum of assumptions it needs to actually work. If your code can work with mutable types, then let it take a mutable