Simplified socket creation and handling

2012-05-17 Thread Jarl André
I am a Java developer who is tired of java.nio and similar complex socket libraries. In Java you got QuickServer, the ultimate protocol creation centered socket library. You don't have to write any channels and readers and what not. You just instantiate a server, configures the handlers (fill

Re: is there a common type?

2012-05-17 Thread Simen Kjaeraas
On Thu, 17 May 2012 16:28:56 +0200, Christian Köstlin wrote: On 5/15/12 19:44 , H. S. Teoh wrote: On Tue, May 15, 2012 at 07:29:38PM +0200, Christian Köstlin wrote: for [1, 2, 3] and iota(2, 10)? [...] What are you trying to accomplish? T actually i just want to do some commandline par

Re: parse json-string - operator overload error

2012-05-17 Thread Jarl André
On Wednesday, 1 December 2010 at 08:17:37 UTC, zusta wrote: Hey guys, I'm trying to read a JSON-formated file. The parsing of the file seems to be correct, but I always get the following error: "Error: no [] operator overload for type JSONValue". For testing purposes, I also tried the code o

Re: std.json

2012-05-17 Thread Jarl André
On Thursday, 17 May 2012 at 18:36:22 UTC, Jarl André wrote: On Thursday, 17 May 2012 at 14:08:27 UTC, Vincent wrote: On Sunday, 25 March 2012 at 17:50:45 UTC, Andrea Fontana wrote: Hope it's clear... Nope, it's something like chess and have nothing common with simplicity of the real JSON usa

Re: std.json

2012-05-17 Thread Jarl André
On Thursday, 17 May 2012 at 14:08:27 UTC, Vincent wrote: On Sunday, 25 March 2012 at 17:50:45 UTC, Andrea Fontana wrote: Hope it's clear... Nope, it's something like chess and have nothing common with simplicity of the real JSON usage! This is example from C#: var p = JsonConvert.Deserializ

Re: Reading ASCII file with some codes above 127 (exten ascii)

2012-05-17 Thread Paul
On Monday, 14 May 2012 at 12:58:20 UTC, Graham Fawcett wrote: On Sunday, 13 May 2012 at 21:03:45 UTC, Paul wrote: I am reading a file that has a few extended ASCII codes (e.g. degree symdol). Depending on how I read the file in and what I do with it the error shows up at different points. I'm

Re: Thread safety of AAs

2012-05-17 Thread Steven Schveighoffer
On Tue, 15 May 2012 22:35:17 -0400, Alex Rønne Petersen wrote: Hi, Suppose that I have an AA that I'm doing lookups on from one thread, and writing to in another. Is this safe at all? No. AA's are not a default-shared type. If you need a counter-case, just consider that your adding thr

Re: DMD Bug or not? foreach over struct range

2012-05-17 Thread Steven Schveighoffer
On Wed, 16 May 2012 03:20:39 -0400, Jonathan M Davis wrote: On Wednesday, May 16, 2012 09:15:06 bearophile wrote: Nick Sabalausky: > It seems that foreach is iterating over an implicit copy of > 'foo' instead of > 'foo' itself. Is this correct behavior, or a DMD bug? This program prints "[1

Re: is there a common type?

2012-05-17 Thread Christian Köstlin
On 5/15/12 20:14 , Ali Çehreli wrote: On 05/15/2012 10:29 AM, Christian Köstlin wrote: for [1, 2, 3] and iota(2, 10)? thanks in advance christian When it comes to compile-time polymorphism or duck typing, they are both RandomAccessRanges. (Pedantically, [1, 2, 3] is not a range (I think :P),

Re: is there a common type?

2012-05-17 Thread Christian Köstlin
On 5/15/12 19:44 , H. S. Teoh wrote: On Tue, May 15, 2012 at 07:29:38PM +0200, Christian Köstlin wrote: for [1, 2, 3] and iota(2, 10)? [...] What are you trying to accomplish? T actually i just want to do some commandline parsing with default-values like this: int main(string[] args) {

Re: std.json

2012-05-17 Thread Vincent
On Sunday, 25 March 2012 at 17:50:45 UTC, Andrea Fontana wrote: Hope it's clear... Nope, it's something like chess and have nothing common with simplicity of the real JSON usage! This is example from C#: var p = JsonConvert.DeserializeObject("{some real JSON, not crapy EOS}"); var str = Js

Re: convert ubyte[k..k + 1] to int

2012-05-17 Thread Artur Skawina
On 05/17/12 11:36, Artur Skawina wrote: >assert(cast(size_t)data.ptr%data.alignof==0); > > This assert can be easily triggered eg by doing > >blob[1..$-4]; blob.assumeSafeAppend(); ++blob.length; >auto data = cast(C[]) blob; Umm, that was meant to be: blob = blob[1..$-4]; bl

Re: convert ubyte[k..k + 1] to int

2012-05-17 Thread Artur Skawina
On 05/17/12 10:47, Roman D. Boiko wrote: > On Thursday, 17 May 2012 at 08:39:21 UTC, Artur Skawina wrote: >> On 05/17/12 10:15, Roman D. Boiko wrote: >>> I mean, is it safe (assuming that we are allowed to mutate blob, and its >>> length is a multiple of C.sizeof)? >>> >>> I do casting from ubyte[

Re: convert ubyte[k..k + 1] to int

2012-05-17 Thread Roman D. Boiko
On Thursday, 17 May 2012 at 08:39:21 UTC, Artur Skawina wrote: On 05/17/12 10:15, Roman D. Boiko wrote: I mean, is it safe (assuming that we are allowed to mutate blob, and its length is a multiple of C.sizeof)? I do casting from ubyte[] to C[]. Only if C.ptr ends up properly aligned. There

Re: convert ubyte[k..k + 1] to int

2012-05-17 Thread Artur Skawina
On 05/17/12 10:15, Roman D. Boiko wrote: > On Thursday, 17 May 2012 at 07:07:58 UTC, Roman D. Boiko wrote: >> And what about the following code: >> >> // This implementation is optimized for speed via swapping >> endianness in-place >> pure immutable(C)[] fixEndian(C, Endian blobEndian = >> endian)

Re: convert ubyte[k..k + 1] to int

2012-05-17 Thread Roman D. Boiko
On Thursday, 17 May 2012 at 07:07:58 UTC, Roman D. Boiko wrote: And what about the following code: // This implementation is optimized for speed via swapping endianness in-place pure immutable(C)[] fixEndian(C, Endian blobEndian = endian)(ubyte[] blob) if(is(CharTypeOf!C)) { import std.bitm

Re: convert ubyte[k..k + 1] to int

2012-05-17 Thread Roman D. Boiko
On Thursday, 17 May 2012 at 04:16:10 UTC, Andrew Wiley wrote: On Wed, May 16, 2012 at 11:07 PM, H. S. Teoh wrote: Do unions suffer from this problem? Could this prevent alignment problems: short bytesToShort(ubyte[] b) in { assert(b.length==2); } body { uni