Re: Building dmd/druntime on windows issue

2018-05-10 Thread Andre Pany via Digitalmars-d-learn
On Thursday, 10 May 2018 at 22:01:25 UTC, Seb wrote: On Thursday, 10 May 2018 at 18:38:30 UTC, Andre Pany wrote: Hi, I follow the instructions from the wiki to build dmd/druntime from source on windows. https://wiki.dlang.org/Building_under_Windows [...] Which DMD/druntime do you try to bu

Re: Line breaks in JSON

2018-05-10 Thread jmh530 via Digitalmars-d-learn
On Thursday, 10 May 2018 at 18:21:17 UTC, bachmeier wrote: [snip] I used replace("\\n", "\n") Ah, I always forget the extra \.

Re: property += operator

2018-05-10 Thread Mike Franklin via Digitalmars-d-learn
On Thursday, 10 May 2018 at 21:16:12 UTC, Jonathan M Davis wrote: IIRC, there's a DIP for trying to make += work with just getters and setters, but I don't know if we're ever going to see anything like it in the language. Yes, the DIP is here: https://github.com/dlang/DIPs/pull/97 It's curr

Re: Building dmd/druntime on windows issue

2018-05-10 Thread Seb via Digitalmars-d-learn
On Thursday, 10 May 2018 at 18:38:30 UTC, Andre Pany wrote: Hi, I follow the instructions from the wiki to build dmd/druntime from source on windows. https://wiki.dlang.org/Building_under_Windows [...] Which DMD/druntime do you try to build? IIRC there are some issues with the release ball,

Re: property += operator

2018-05-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 10, 2018 18:43:40 SrMordred via Digitalmars-d-learn wrote: > struct T > { > int x; > @property ref X(){ return x; } > @property X(int v) > { > x = v; > } > } > > T t; > t.X += 10; > > The setter 'x = v' are not executed because i´m returning the >

Re: D'ish similar_text?

2018-05-10 Thread Dgame via Digitalmars-d-learn
On Thursday, 10 May 2018 at 20:38:12 UTC, Vladimir Panteleev wrote: On Thursday, 10 May 2018 at 20:32:11 UTC, Dgame wrote: immutable size_t len = s1.length + s2.length; percent = (len - distance) * 100.0 / len; Note that this formula will give you only 50% similarity for "abc" and "de

Re: property += operator

2018-05-10 Thread Dlang User via Digitalmars-d-learn
On 5/10/2018 3:18 PM, Ali Çehreli wrote: On 05/10/2018 01:03 PM, Dlang User wrote: >> this didn´t work either. >> note that 'f.data+= 2;' don't call the write property > > That's odd, it works on my machine (Windows 10 with V2.079.0 DMD compiler). Try putting writeln expressions in the tw

Re: How do you connect Python with D via socket, I'm still getting connection refused error

2018-05-10 Thread Enjoys Math via Digitalmars-d-learn
On Friday, 4 May 2018 at 13:52:29 UTC, Andy Smith wrote: On Thursday, 3 May 2018 at 23:58:24 UTC, Enjoys Math wrote: Error - [...] Haven't run it, but two things to try... On D side try adding listen after bind. On python side. Don't think you need to call bind the client socket (

Re: D'ish similar_text?

2018-05-10 Thread Vladimir Panteleev via Digitalmars-d-learn
On Thursday, 10 May 2018 at 20:32:11 UTC, Dgame wrote: immutable size_t len = s1.length + s2.length; percent = (len - distance) * 100.0 / len; Note that this formula will give you only 50% similarity for "abc" and "def", i.e. two completely different strings. I suggest to divide by ma

Re: D'ish similar_text?

2018-05-10 Thread Dgame via Digitalmars-d-learn
On Thursday, 10 May 2018 at 20:13:49 UTC, Vladimir Panteleev wrote: On Thursday, 10 May 2018 at 20:08:04 UTC, Dgame wrote: void similar_text_similar_str(char* txt1, size_t len1, char* That looks like an implementation of Levenshtein distance. We have one in Phobos: https://dlang.org/library

Re: property += operator

2018-05-10 Thread Ali Çehreli via Digitalmars-d-learn
On 05/10/2018 01:03 PM, Dlang User wrote: >> this didn´t work either. >> note that 'f.data+= 2;' don't call the write property > > That's odd, it works on my machine (Windows 10 with V2.079.0 DMD compiler). Try putting writeln expressions in the two functions to see which one gets called. ;)

Re: D'ish similar_text?

2018-05-10 Thread Vladimir Panteleev via Digitalmars-d-learn
On Thursday, 10 May 2018 at 20:08:04 UTC, Dgame wrote: void similar_text_similar_str(char* txt1, size_t len1, char* That looks like an implementation of Levenshtein distance. We have one in Phobos: https://dlang.org/library/std/algorithm/comparison/levenshtein_distance.html

D'ish similar_text?

2018-05-10 Thread Dgame via Digitalmars-d-learn
I'm in need for some sort of string similarity comparision. I've found soundex but that didn't solved my needs. After some search I found a C implementation of similar_text, but that is quite ugly... I was able to let it work in D but it's still somewhat messy. Is there any D implementation of

Re: property += operator

2018-05-10 Thread Dlang User via Digitalmars-d-learn
On 5/10/2018 2:50 PM, SrMordred wrote: On Thursday, 10 May 2018 at 19:41:41 UTC, Dlang User wrote: On 5/10/2018 1:43 PM, SrMordred wrote: [...] I am relatively new to D and I was under the impression that that was a limitation of @property functions. But, re-reading the language reference,

Re: property += operator

2018-05-10 Thread SrMordred via Digitalmars-d-learn
On Thursday, 10 May 2018 at 19:41:41 UTC, Dlang User wrote: On 5/10/2018 1:43 PM, SrMordred wrote: [...] I am relatively new to D and I was under the impression that that was a limitation of @property functions. But, re-reading the language reference, it gave this example (it returns somet

Re: property += operator

2018-05-10 Thread Dlang User via Digitalmars-d-learn
On 5/10/2018 1:43 PM, SrMordred wrote: struct T {     int x;     @property ref X(){ return x; }     @property X(int v)     {     x = v;     } } T t; t.X += 10; The setter 'x = v' are not executed because i´m returning the reference of x. And without the 'ref' the compiler complains

Re: Extra .tupleof field in structs with disabled postblit blocks non-GC-allocation trait

2018-05-10 Thread Meta via Digitalmars-d-learn
On Thursday, 10 May 2018 at 12:55:36 UTC, Uknown wrote: On Thursday, 10 May 2018 at 11:06:06 UTC, Per Nordlöw wrote: On Wednesday, 9 May 2018 at 21:09:12 UTC, Meta wrote: It's a context pointer to the enclosing function/object/struct. Mark the struct as static to get rid of it. Ok, but why a

property += operator

2018-05-10 Thread SrMordred via Digitalmars-d-learn
struct T { int x; @property ref X(){ return x; } @property X(int v) { x = v; } } T t; t.X += 10; The setter 'x = v' are not executed because i´m returning the reference of x. And without the 'ref' the compiler complains because 'x' is not a lvalue. Any solution to

Building dmd/druntime on windows issue

2018-05-10 Thread Andre Pany via Digitalmars-d-learn
Hi, I follow the instructions from the wiki to build dmd/druntime from source on windows. https://wiki.dlang.org/Building_under_Windows Building dmd ends with following text: --- copy ..\generated\windows\release\32\dmd.exe . 1 file copied. make -fwin32.mak C=dmd\bac

Re: Line breaks in JSON

2018-05-10 Thread bachmeier via Digitalmars-d-learn
On Thursday, 10 May 2018 at 17:59:26 UTC, jmh530 wrote: On Thursday, 10 May 2018 at 15:01:57 UTC, rikki cattermole wrote: [snip] You'll need to unescape them (which is pretty easy, a simple replacement here). For reference, this is invalid json[0]: ``` { "1 2 3 " } `

Re: Line breaks in JSON

2018-05-10 Thread jmh530 via Digitalmars-d-learn
On Thursday, 10 May 2018 at 15:01:57 UTC, rikki cattermole wrote: [snip] You'll need to unescape them (which is pretty easy, a simple replacement here). For reference, this is invalid json[0]: ``` { "1 2 3 " } ``` [0] https://jsonlint.com/ I don't see an unescape f

Re: Line breaks in JSON

2018-05-10 Thread bachmeier via Digitalmars-d-learn
On Thursday, 10 May 2018 at 15:01:57 UTC, rikki cattermole wrote: You'll need to unescape them (which is pretty easy, a simple replacement here). For reference, this is invalid json[0]: ``` { "1 2 3 " } ``` [0] https://jsonlint.com/ So I see the answer is that I don

Re: Line breaks in JSON

2018-05-10 Thread rikki cattermole via Digitalmars-d-learn
On 11/05/2018 2:56 AM, bachmeier wrote: I'm using std.json for the first time. I want to download the contents of a markdown file from a web server. When I do that, the line breaks are escaped, which I don't want. Here's an example: import std.conv, std.json, std.stdio; void main() { str

Line breaks in JSON

2018-05-10 Thread bachmeier via Digitalmars-d-learn
I'm using std.json for the first time. I want to download the contents of a markdown file from a web server. When I do that, the line breaks are escaped, which I don't want. Here's an example: import std.conv, std.json, std.stdio; void main() { string data = "This is a paragraph with

Re: Package method is not virtual and cannot override - a bug or a feature?

2018-05-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 10, 2018 11:52:38 Piotr Mitana via Digitalmars-d-learn wrote: > Given this code: > > abstract class A > { > package @property void x(int x); > package @property int x(); > } > > class B : A > { > package @property override void x(int x) {} > package @property o

Re: Extra .tupleof field in structs with disabled postblit blocks non-GC-allocation trait

2018-05-10 Thread Uknown via Digitalmars-d-learn
On Thursday, 10 May 2018 at 11:06:06 UTC, Per Nordlöw wrote: On Wednesday, 9 May 2018 at 21:09:12 UTC, Meta wrote: It's a context pointer to the enclosing function/object/struct. Mark the struct as static to get rid of it. Ok, but why an extra void* for `S.tupleof` and not for `T.tupleof` wh

Package method is not virtual and cannot override - a bug or a feature?

2018-05-10 Thread Piotr Mitana via Digitalmars-d-learn
Given this code: abstract class A { package @property void x(int x); package @property int x(); } class B : A { package @property override void x(int x) {} package @property override int x() { return 0; } } void main() {} I get the following message: onlineapp.d(9): Error: fun

Re: Extra .tupleof field in structs with disabled postblit blocks non-GC-allocation trait

2018-05-10 Thread Per Nordlöw via Digitalmars-d-learn
On Wednesday, 9 May 2018 at 21:09:12 UTC, Meta wrote: It's a context pointer to the enclosing function/object/struct. Mark the struct as static to get rid of it. Ok, but why an extra void* for `S.tupleof` and not for `T.tupleof` which is also scoped inside a unittest?

Re: Error: module `hello` is in file 'hello.d' which cannot be read

2018-05-10 Thread phongkhamdakhoathegioi via Digitalmars-d-learn
On Saturday, 5 May 2018 at 10:39:17 UTC, Alex wrote: Thank you for you for your quick answer. I think I allready tryed this, before asking, but ... C:\>cd D\dmd2\sources C:\D\dmd2\sources>dmd hello.d Error: module `hello` is in file 'hello.d' which cannot be read import path[0] = C:\D\dmd2\win