Re: Connecting python to D on socket of localhost : target machine actively refuses connection

2017-09-23 Thread Sergei Degtiarev via Digitalmars-d-learn
On Saturday, 23 September 2017 at 02:50:25 UTC, rikki cattermole wrote: On 23/09/2017 3:26 AM, Sergei Degtiarev wrote: On Friday, 22 September 2017 at 04:06:08 UTC, Enjoys Math wrote: Here's my minimal D code (server.d): public: this(ushort port, string address="") {     super(& run);

Re: Connecting python to D on socket of localhost : target machine actively refuses connection

2017-09-22 Thread Sergei Degtiarev via Digitalmars-d-learn
On Friday, 22 September 2017 at 04:06:08 UTC, Enjoys Math wrote: Here's my minimal D code (server.d): public: this(ushort port, string address="") { super(& run); if (address == "") address = "DESKTOP-T49RGUJ";

Re: Binary serialization of a struct

2017-09-16 Thread Sergei Degtiarev via Digitalmars-d-learn
On Saturday, 16 September 2017 at 03:30:51 UTC, Joseph wrote: Are there any simple direct serialization libraries... I want something straight forward without allot of plumbing on my end. You may also take a look at https://github.com/sdegtiarev/persistentObject This is small module for

Re: std.algorithm.joiner unexpected behavior

2017-09-11 Thread Sergei Degtiarev via Digitalmars-d-learn
On Friday, 1 September 2017 at 00:09:16 UTC, H. S. Teoh wrote: Consider the case where .front returns a subrange. As you state above, copying this subrange does not have defined behaviour. One reason is the difference in semantics between reference types and value types: the assignment

Re: std.algorithm.joiner unexpected behavior

2017-09-02 Thread Sergei Degtiarev via Digitalmars-d-learn
Let me clarify, what I was going to create was a small utility, analogous to Perl <> operator, taking a list of file names and allowing forward iteration as it would be single stream of text lines. It would take no time to write the range from scratch, but what are all the phobos primitives

std.algorithm.joiner unexpected behavior

2017-08-31 Thread Sergei Degtiarev via Digitalmars-d-learn
Hi, I tried to create a simple range concatenating several files, something like this: File[] files; foreach(ln; joiner(files.map!(a => a.byLine))) writeln(ln); and I see every first line of each file is missing. However, when I do same thing with

Re: Casting away immutability

2015-09-03 Thread Sergei Degtiarev via Digitalmars-d-learn
On Thursday, 3 September 2015 at 14:36:12 UTC, Mike Parker wrote: immutable(T)[] getGetData(T)() { return cast(immutable(T)[])data; } Absolutely, instead of returning raw void[] and allow user to cast it, std.mmfile should implement template function to return desired type. This would

Re: Casting away immutability

2015-09-03 Thread Sergei Degtiarev via Digitalmars-d-learn
On Thursday, 3 September 2015 at 05:15:35 UTC, Jonathan M Davis wrote: On Wednesday, September 02, 2015 14:00:07 Sergei Degtiarev via Digitalmars-d-learn wrote: Well, that's how mmap works. You're just getting raw bytes as void*, and the D code converts that to void[], which is slightly safer

Re: Casting away immutability

2015-09-02 Thread Sergei Degtiarev via Digitalmars-d-learn
On Wednesday, 2 September 2015 at 04:19:24 UTC, lobo wrote: No, I think your design is unsafe because you're throwing away type information and returning void[], then telling the compiler not to worry about it. It is unsafe, but this not my design but std.mmfile module in phobos. This is what

Casting away immutability

2015-09-01 Thread Sergei Degtiarev via Digitalmars-d-learn
I can't understand how cast coexist with immutability. Consider the code: immutable immutable(int)[4] buf; auto x=buf[0]; auto p=buf.ptr; auto i=cast(int[]) buf; i[]=1; assert(buf.ptr == p); assert(buf[0] != x); I've just

Re: Casting away immutability

2015-09-01 Thread Sergei Degtiarev via Digitalmars-d-learn
On Wednesday, 2 September 2015 at 02:50:30 UTC, Jonathan M Davis wrote: is undefined behavior. So, don't do it. I don't. Actually, I'm looking for opposite - to protect data, like it is a class with two methods, returning void[] and immutable(void)[] as memory buffer, which user of the class