wmemchar for unix

2013-08-27 Thread monarch_dodra
For performance reasons, I need a "w" version of memchr. C defines wmemchr as: wchar_t * wmemchr ( const wchar_t *, wchar_t, size_t ); Unfortunatly, on unix, "wchar_t" is defined a *4* bytes long, making wmemchr, effectivelly, "dmemchr". Are there any "2 byte" alternatives for wmemchr on unix?

Re: Test

2013-08-27 Thread Mike Parker
On 8/27/2013 4:56 PM, Mike Parker wrote: Sorry for the noise. Having some difficulty with my newsreader. Last one.

Test

2013-08-27 Thread Mike Parker
Sorry for the noise. Having some difficulty with my newsreader.

Re: How to cleanup after Socket.bind on Linux?

2013-08-27 Thread Regan Heath
On Tue, 27 Aug 2013 04:30:10 +0100, Ali Çehreli wrote: The following simple socket example is trying to cleanup after itself, except the bind() call. As I repeat in the QUESTION comment below, I have read the man page of bind and I know that I need to unlink a path. How can I get that path?

Re: template definitions spanning modules.

2013-08-27 Thread Nicolas Sicard
On Monday, 26 August 2013 at 00:46:50 UTC, Jason den Dulk wrote: Hi Consider the following code module A; void xx(T:int)(T t) { .. } void xx(T:float)(T t) { .. } module B; import A; void xx(T:string)(T t) { .. } void main() { xx!(int)(4); xx(4.5); xx("abc"); } The compiler won't le

Re: Variant[Variant]

2013-08-27 Thread Jason den Dulk
Hi Ali, thanks for helping me out. On Tuesday, 27 August 2013 at 01:38:54 UTC, Ali Çehreli wrote: I spent 15 minutes trying to complete the code but failed. Could you please provide a minimal program that almost compiles. I uploaded a new version with a main routine. So you know, I am using D

Re: ElementType!string

2013-08-27 Thread Jason den Dulk
On Sunday, 25 August 2013 at 19:38:52 UTC, Paolo Invernizzi wrote: Thanks, somewhat unintuitive. It is a trap for the unwary, but in this case the benefits outweigh the costs. On Sunday, 25 August 2013 at 19:56:34 UTC, Jakob Ovrum wrote: To get a range of UTF-8 or UTF-16 code units, the co

Re: ElementType!string

2013-08-27 Thread Tobias Pankrath
On Tuesday, 27 August 2013 at 11:43:29 UTC, Jason den Dulk wrote: On Sunday, 25 August 2013 at 19:38:52 UTC, Paolo Invernizzi wrote: Thanks, somewhat unintuitive. It is a trap for the unwary, but in this case the benefits outweigh the costs. On Sunday, 25 August 2013 at 19:56:34 UTC, Jako

Re: Freshly Compiled DMD + Visual Studio

2013-08-27 Thread Dmitry Olshansky
27-Aug-2013 08:46, Meta пишет: I decided to compile D from Github for the first time, and everything seemed to be working. I can build and run stuff fine from the command line. However, then I tried to make Visual Studio use my newly compiled DMD, and things blew up. I'm using VisualD 0.3.37. Whe

Re: ElementType!string

2013-08-27 Thread monarch_dodra
On Tuesday, 27 August 2013 at 11:43:29 UTC, Jason den Dulk wrote: On Sunday, 25 August 2013 at 19:38:52 UTC, Paolo Invernizzi wrote: Thanks, somewhat unintuitive. It is a trap for the unwary, but in this case the benefits outweigh the costs. On Sunday, 25 August 2013 at 19:56:34 UTC, Jako

repeating random number sequences.

2013-08-27 Thread Jason den Dulk
Hi This code foreach (j; 0..5) writeln(rndGen().take(5)); writeln(uniform(0, 1024)); foreach (j; 0..5) writeln(rndGen().take(5)); produces this output [3410716173, 2484862302, 280352965, 1820347603, 850366086] [3410716173, 2484862302, 280352965, 1820347603, 850366086] [3410

Re: repeating random number sequences.

2013-08-27 Thread monarch_dodra
On Tuesday, 27 August 2013 at 12:59:19 UTC, Jason den Dulk wrote: Hi This code foreach (j; 0..5) writeln(rndGen().take(5)); writeln(uniform(0, 1024)); foreach (j; 0..5) writeln(rndGen().take(5)); produces this output [3410716173, 2484862302, 280352965, 1820347603, 850366086]

Re: Freshly Compiled DMD + Visual Studio

2013-08-27 Thread Meta
On Tuesday, 27 August 2013 at 12:09:22 UTC, Dmitry Olshansky wrote: Linker errors are typically solve by doing clean, then rebuilding from source. There is a decent chance that you (or VisualD) do separate compilation and old object files can't find matching symbols in the new runtime library.

Re: Freshly Compiled DMD + Visual Studio

2013-08-27 Thread Andre Artus
On Tuesday, 27 August 2013 at 13:32:06 UTC, Meta wrote: On Tuesday, 27 August 2013 at 12:09:22 UTC, Dmitry Olshansky wrote: Linker errors are typically solve by doing clean, then rebuilding from source. There is a decent chance that you (or VisualD) do separate compilation and old object files

Re: Freshly Compiled DMD + Visual Studio

2013-08-27 Thread Meta
On Tuesday, 27 August 2013 at 13:55:55 UTC, Andre Artus wrote: Check that your library paths are all set to the path for of the newly built Phobos. It may be that it's trying to link in the old library. Of course it was something as simple as that. Thank you Andre.

Re: wmemchar for unix

2013-08-27 Thread Sean Kelly
On Aug 26, 2013, at 11:57 PM, monarch_dodra wrote: > For performance reasons, I need a "w" version of memchr. > > C defines wmemchr as: > wchar_t * wmemchr ( const wchar_t *, wchar_t, size_t ); > > Unfortunatly, on unix, "wchar_t" is defined a *4* bytes long, > making wmemchr, effectivelly, "dm

Re: wmemchar for unix

2013-08-27 Thread H. S. Teoh
On Tue, Aug 27, 2013 at 07:37:02AM -0700, Sean Kelly wrote: > On Aug 26, 2013, at 11:57 PM, monarch_dodra wrote: > > > For performance reasons, I need a "w" version of memchr. > > > > C defines wmemchr as: > > wchar_t * wmemchr ( const wchar_t *, wchar_t, size_t ); > > > > Unfortunatly, on unix

Re: Freshly Compiled DMD + Visual Studio

2013-08-27 Thread Andre Artus
On Tuesday, 27 August 2013 at 14:04:09 UTC, Meta wrote: On Tuesday, 27 August 2013 at 13:55:55 UTC, Andre Artus wrote: Check that your library paths are all set to the path for of the newly built Phobos. It may be that it's trying to link in the old library. Of course it was something as sim

Strange behavior of read file

2013-08-27 Thread Paul Jurczak
module main; import std.stdio, std.file, std.string, std.algorithm, std.range, std.datetime, std.conv, std.typetuple; int f(string fileName = r"C:\Euler\data\e67.txt") { auto text = read(fileName); return text.length; } void main() { try { string fileName = r"C:\Euler\data\e67.t

Re: wmemchar for unix

2013-08-27 Thread monarch_dodra
On Tuesday, 27 August 2013 at 14:37:14 UTC, Sean Kelly wrote: On Aug 26, 2013, at 11:57 PM, monarch_dodra wrote: For performance reasons, I need a "w" version of memchr. C defines wmemchr as: wchar_t * wmemchr ( const wchar_t *, wchar_t, size_t ); Unfortunatly, on unix, "wchar_t" is defined

Re: wmemchar for unix

2013-08-27 Thread monarch_dodra
On Tuesday, 27 August 2013 at 14:43:10 UTC, H. S. Teoh wrote: On Tue, Aug 27, 2013 at 07:37:02AM -0700, Sean Kelly wrote: On Aug 26, 2013, at 11:57 PM, monarch_dodra wrote: > For performance reasons, I need a "w" version of memchr. > > C defines wmemchr as: > wchar_t * wmemchr ( const wchar

Re: Strange behavior of read file

2013-08-27 Thread Paul Jurczak
Correction to my initial post: I oversimplified the code example by snipping too much of context. Here is an example, which fails both on Windows and Linux: module main; import std.stdio, std.file, std.string, std.algorithm, std.range, std.datetime, std.conv, std.typetuple; int e67_1(stri

Re: Strange behavior of read file

2013-08-27 Thread monarch_dodra
On Tuesday, 27 August 2013 at 15:45:06 UTC, Paul Jurczak wrote: module main; import std.stdio, std.file, std.string, std.algorithm, std.range, std.datetime, std.conv, std.typetuple; int f(string fileName = r"C:\Euler\data\e67.txt") { auto text = read(fileName); return text.length; } vo

Re: Strange behavior of read file

2013-08-27 Thread H. S. Teoh
On Tue, Aug 27, 2013 at 07:14:22PM +0200, Paul Jurczak wrote: > Correction to my initial post: > > I oversimplified the code example by snipping too much of context. > Here is an example, which fails both on Windows and Linux: > > module main; > > import std.stdio, std.file, std.string, std.algo

Re: Strange behavior of read file

2013-08-27 Thread monarch_dodra
On Tuesday, 27 August 2013 at 17:14:23 UTC, Paul Jurczak wrote: Correction to my initial post: I'll investigate later then.

Re: improve concurrent queue

2013-08-27 Thread qznc
On Monday, 26 August 2013 at 19:35:28 UTC, luminousone wrote: I have been working on a project and needed a good concurrent queue What does "good" mean? Concurrent queues have so many design parameters (single reader? single writer? blocking? bounded? etc) and there is no queue, which perform

Re: Strange behavior of read file

2013-08-27 Thread monarch_dodra
On Tuesday, 27 August 2013 at 17:19:08 UTC, monarch_dodra wrote: On Tuesday, 27 August 2013 at 17:14:23 UTC, Paul Jurczak wrote: Correction to my initial post: I'll investigate later then. I am unable to reproduce.

Re: Variant[Variant]

2013-08-27 Thread Ali Çehreli
On 08/27/2013 03:53 AM, Jason den Dulk wrote: > I uploaded a new version with a main routine. So you know, I am using > DMD 2.063.2 on Fedora 15. > > The code should compile with "dmd serialize.d". And it's here: http://jaypha.com.au/serialize.d > I since realized that I was not dealing with

Re: wmemchar for unix

2013-08-27 Thread Dmitry Olshansky
27-Aug-2013 18:41, H. S. Teoh пишет: On Tue, Aug 27, 2013 at 07:37:02AM -0700, Sean Kelly wrote: On Aug 26, 2013, at 11:57 PM, monarch_dodra wrote: For performance reasons, I need a "w" version of memchr. C defines wmemchr as: wchar_t * wmemchr ( const wchar_t *, wchar_t, size_t ); Unfortun

Re: wmemchar for unix

2013-08-27 Thread H. S. Teoh
On Tue, Aug 27, 2013 at 11:18:50PM +0400, Dmitry Olshansky wrote: > 27-Aug-2013 18:41, H. S. Teoh пишет: > >On Tue, Aug 27, 2013 at 07:37:02AM -0700, Sean Kelly wrote: > >>On Aug 26, 2013, at 11:57 PM, monarch_dodra wrote: > >> > >>>For performance reasons, I need a "w" version of memchr. > >>> >

Re: improve concurrent queue

2013-08-27 Thread luminousone
On Tuesday, 27 August 2013 at 17:35:13 UTC, qznc wrote: On Monday, 26 August 2013 at 19:35:28 UTC, luminousone wrote: I have been working on a project and needed a good concurrent queue What does "good" mean? Concurrent queues have so many design parameters (single reader? single writer? bloc

Re: wmemchar for unix

2013-08-27 Thread Dmitry Olshansky
27-Aug-2013 23:31, H. S. Teoh пишет: On Tue, Aug 27, 2013 at 11:18:50PM +0400, Dmitry Olshansky wrote: 27-Aug-2013 18:41, H. S. Teoh пишет: [snip] I'm not sure if dmd does that optimization. If you really feel inclined, you could do static if (X86) and throw in an asm block (but that would b

Re: Strange behavior of read file

2013-08-27 Thread Ramon
I played a little with it int f(string fileName = r"someExistingPath") { auto text = read(fileName); return text.length; } void main() { try { string fileName = r"someExistingPath"; if(exists(fileName)) writeln("File '", fileName, "' does exist."); auto text =

Re: Strange behavior of read file

2013-08-27 Thread Justin Whear
On Wed, 28 Aug 2013 00:51:12 +0200, Ramon wrote: > > - trying with filename r"~/text.txt" (i.e. an existing file in my home > dir) it FAILED. > > - trying with the same filename but this time home dir explicitely > written out fully (r"/home/me/test.txt) it WORKED. > > Conclusion: I assume D's

Re: Strange behavior of read file

2013-08-27 Thread H. S. Teoh
On Wed, Aug 28, 2013 at 12:51:12AM +0200, Ramon wrote: [...] > Here's what I came up with (on linux): > > - trying with filename r"~/text.txt" (i.e. an existing file in my > home dir) it FAILED. > > - trying with the same filename but this time home dir explicitely > written out fully (r"/home/me

Re: Strange behavior of read file

2013-08-27 Thread Jesse Phillips
On Tuesday, 27 August 2013 at 17:14:23 UTC, Paul Jurczak wrote: Correction to my initial post: I oversimplified the code example by snipping too much of context. Here is an example, which fails both on Windows and Linux: I get a range violation in Linux, but that is to be expected since my

Re: Strange behavior of read file

2013-08-27 Thread Ramon
Justin Whear & H.S. Teoh Yep, that's what I assumed, too. But that's so C Style. Wouldn't it befit phobos to have sth. like normalizePath? Like: On Unix/linux rep ' ' with '\ ' " replace ~ with $HOME etc. so as to have normalizePath return a path equal to what the shell would do?

Regarding std.collection.Array

2013-08-27 Thread bearophile
Is it a good idea to add to std.collection.Array a method similar to: T[] unsafeRelease() pure nothrow { return this._data._payload; } It's meant to be used as an unsafe hack to call some some functions that require a built-in array as input. Bye, bearophile

Re: Limited Semi-PolyMorphic (LSP) structs?

2013-08-27 Thread Era Scarecrow
It just came to mind that what I want is almost more a unioned struct. Perhaps this will come up with something closer to what I am really looking for. assuming we could use a union, it would be closer to: //type is the identifier of which one it's going to be using union AB { iA ia; iB i

Re: Limited Semi-PolyMorphic (LSP) structs?

2013-08-27 Thread Andre Artus
Era, I haven't had time to go through your everything you wrote here but are you looking to create some form of discriminated union (AKA tagged union) using D structs? Do you have a specific problem you need to solve, or are you just exploring the language?

Re: Strange behavior of read file

2013-08-27 Thread Paul Jurczak
On Tuesday, 27 August 2013 at 17:19:08 UTC, monarch_dodra wrote: On Tuesday, 27 August 2013 at 17:14:23 UTC, Paul Jurczak wrote: Correction to my initial post: I'll investigate later then. monarch_dodra, H. S. Teoh, Ramon, Justin Whear, Jesse Phillips: Sorry for the delay in responding - I

Re: How to cleanup after Socket.bind on Linux?

2013-08-27 Thread Ali Çehreli
On 08/27/2013 02:02 AM, Regan Heath wrote: > You could set the REUSE option on the socket prior to 'bind', this would > allow you to bind again while the previous socket was in cleanup. That worked. I copied the following line from std/socket.d: listener.setOption(SocketOptionLevel.SOCKET,

Re: Limited Semi-PolyMorphic (LSP) structs?

2013-08-27 Thread H. S. Teoh
On Wed, Aug 28, 2013 at 06:45:11AM +0200, Era Scarecrow wrote: > On Wednesday, 28 August 2013 at 03:45:06 UTC, Andre Artus wrote: > >Era, > > > >I haven't had time to go through your everything you wrote here > >but are you looking to create some form of discriminated union > >(AKA tagged union) us

Re: Limited Semi-PolyMorphic (LSP) structs?

2013-08-27 Thread Era Scarecrow
On Wednesday, 28 August 2013 at 05:13:51 UTC, H. S. Teoh wrote: One trick that you may find helpful, is to use alias this to simulate struct inheritance: struct Base { int x; } struct Derived1 { Base __base; alias __base t