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 currently stalled while I elaborate on the merits, or lack 
thereof, of a library solution.  The best library implementation 
I've seen is 
https://forum.dlang.org/post/mqveusvzkmkshrzws...@forum.dlang.org


I'm exploring the idea of continuing with the DIP, or adding 
features (or removing limitations of the language) to make a 
library implementation more appealing.  IMO, it'd be great if we 
could add more composable primitives to the language, and get rid 
of quirky features like @property.


Mike




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: 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, you should try 
the GitHub sources.

Also are you using DigitalMars make?
What environment variables did you set?


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
> reference of x.
> And without the 'ref' the compiler complains because 'x' is not a
> lvalue.
>
> Any solution to make it work like native arr.length+=10 works?
>
> ( I Thought on returning a struct with "+=" operator but it is a
> strange solution )

Just in general, I would suggest that you not provide both a getter and a
setter if the getter returns by ref. If that's what you're doing, then just
use the getter as the setter. In general though, with getters and setters,
you can only get and set a value. Stuff like += won't work unless you return
by ref (which frequently makes having a function instead of just making the
variable public kind of pointless) or if you play games like returning an
object that overrides opOpAssign!"+" which gets kind of weird and
complicated, albeit sometimes reasonable and useful.

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.

- Jonathan M Davis




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 "def", i.e. two completely different strings. I 
suggest to divide by max(s1.length, s2.length) instead.


Hm, that does not work either. ABC and AZB have a different 
outcome with both. How can I calculate the percentage with 
levenshtein? It's rather simple with similar_text since it 
returns the amount of similar chars.


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 two functions to see which one 
gets called. ;)


Ali



Now, I see the problem. Sorry for the noise.




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 ( this may cause problems).


Cheers,

A.


That got it to work, nvm.


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 max(s1.length, s2.length) instead.


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/std/algorithm/comparison/levenshtein_distance.html


Oh, that could to work, thank you. I've just tested it quickly, 
but that code seems to produce the same results:



size_t similar_text2(in string s1, in string s2, out double 
percent) {

import std.algorithm: levenshteinDistance;

immutable size_t distance = s1.levenshteinDistance(s2);
immutable size_t len = s1.length + s2.length;
percent = (len - distance) * 100.0 / len;

return distance;
}



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. ;)


Ali



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 similar_text? Here's my 
current code which makes heavy use of pointer-arithmetic which 
makes it hard to understand.



void similar_text_similar_str(char* txt1, size_t len1, char* 
txt2, size_t len2, size_t* pos1, size_t* pos2, size_t* max) {

char* p, q;
char* end1 = txt1 + len1;
char* end2 = txt2 + len2;
size_t l;

*max = 0;
for (p = txt1; p < end1; p++) {
for (q = txt2; q < end2; q++) {
for (l = 0; (p + l < end1) && (q + l < end2) && (p[l] 
== q[l]); l++) { }

if (l > *max) {
*max = l;
*pos1 = p - txt1;
*pos2 = q - txt2;
}
}
}
}

size_t similar_text_similar_char(char* txt1, size_t len1, char* 
txt2, size_t len2) {

size_t sum;
size_t pos1, pos2, max;

similar_text_similar_str(txt1, len1, txt2, len2, , 
, );

if ((sum = max) != 0) {
if (pos1 && pos2)  {
sum += similar_text_similar_char(txt1, pos1, txt2, 
pos2);

}
if ((pos1 + max < len1) && (pos2 + max < len2)) {
sum += similar_text_similar_char(txt1 + pos1 + max, 
len1 - pos1 - max,

txt2 + pos2 + max, len2 - pos2 - max);
}
}

return sum;
}

size_t similar_text(in string s1, in string s2, out double 
percent) {
immutable size_t sim = similar_text_similar_char(s1.dup.ptr, 
s1.length, s2.dup.ptr, s2.length);

percent = sim * 200.0 / (s1.length + s2.length);

return sim;
}



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, it gave this example (it 
returns something from the write property, which seems odd), I 
modified to add refs, and then it seems to work, but I am not sure if 
it is correct or not:


import std.stdio;

struct Foo
{
    @property ref int data() { return m_data; } // read property

    @property ref int data(int value) { return m_data = value; } // 
write property


  private:
    int m_data;
}

void main()
{
Foo f;
f.data = 5;
f.data++;
f.data+= 2;
writeln(f.data);

}


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).


I changed main to this:

void main()
{
Foo f;
writeln(f.data);
f.data = 5;
writeln(f.data);
f.data++;
writeln(f.data);
f.data+= 2;
writeln(f.data);
}


and then I get this output:

0
5
6
8



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 something from the write property, which seems 
odd), I modified to add refs, and then it seems to work, but I 
am not sure if it is correct or not:


import std.stdio;

struct Foo
{
@property ref int data() { return m_data; } // read property

@property ref int data(int value) { return m_data = value; 
} // write property


  private:
int m_data;
}

void main()
{
Foo f;
f.data = 5;
f.data++;
f.data+= 2;
writeln(f.data);

}


this didn´t work either.
note that 'f.data+= 2;' don't call the write property


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 because 'x' is not a lvalue.

Any solution to make it work like native arr.length+=10 works?

( I Thought on returning a struct with "+=" operator but it is a strange 
solution )


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 
something from the write property, which seems odd), I modified to add 
refs, and then it seems to work, but I am not sure if it is correct or not:


import std.stdio;

struct Foo
{
@property ref int data() { return m_data; } // read property

@property ref int data(int value) { return m_data = value; } // 
write property


  private:
int m_data;
}

void main()
{
Foo f;
f.data = 5;
f.data++;
f.data+= 2;
writeln(f.data);

}



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 an extra void* for `S.tupleof` and not for 
`T.tupleof` which is also scoped inside a unittest?


I'm guessing T is a POD, so it doesn't need a context pointer, 
whereas S is not counted as a POD since a member function was 
@disabled.


Yes, exactly. From my tests, if you add _any_ member method to a 
struct, it becomes non-POD. When you think about it, this makes 
perfect sense, as there's no possible way to access anything 
through a context pointer if there is no executable code within 
the struct's scope.


As far an @disabled postblit:

Plain Old Data
A struct or union is Plain Old Data (POD) if it meets the 
following criteria:


it is not nested
it has no postblits, destructors, or assignment operators
it has no ref fields or fields that are themselves non-PO

https://docarchives.dlang.io/v2.079.0/spec/struct.html#POD

Now if you do this:

struct R
{
@disable this(this);
int* _ptr;
}
unittest
{
struct S
{
@disable this(this);
int* _ptr;
}
struct T
{
int* _ptr;
}
pragma(msg, "R: ", typeof(R.tupleof));
pragma(msg, __traits(allMembers, R));

pragma(msg, "S: ", typeof(S.tupleof));
pragma(msg, __traits(allMembers, S));

pragma(msg, "T: ", typeof(T.tupleof));
pragma(msg, __traits(allMembers, T));
}

It prints:

R: (int*)
tuple("__postblit", "_ptr", "__xpostblit", "opAssign")

S: (int*, void*)
tuple("__postblit", "_ptr", "this", "__xpostblit", "opAssign")

T: (int*)
tuple("_ptr")

So it looks like disabling a struct's postblit actually counts as 
having a __postblit and __xpostblit function (don't ask me why), 
in addition to a construction and opAssign... no idea why, and 
maybe this is a bug, but I bet there's a good reason for it.


Anyway, as per my first point, this means it'll need a context 
pointer unless you mark the struct as static.


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 make it work like native arr.length+=10 works?

( I Thought on returning a struct with "+=" operator but it is a 
strange solution )


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\backend TK=dmd\tk ROOT=dmd\root 
MAKE="make" HOST_DC="dmd" MODEL=32 CC="dmc" LIB="lib" OBJ_MSVC="" 
clean

rmdir /s /q ..\generated
del dmd\msgs.h dmd\msgs.c
C:\D\dmd2\src\dmd\src\dmd\msgs.h cannot be found
del optabgen.exe parser_test.exe example_avg.exe
del ..\generated\windows\release\32\dmd.exe 
..\generated\windows\release\32\dmd_frontend.exe *.map *.obj *.exe

The system cannot find the given path.
---

If my understanding is correct, there are several issues:
- File dmd\msgs.h does not exist
- make deletes path "generated" which is needed in a further step.

There is a file "C:\D\dmd2\src\dmd\src\dmd.exe" created which 
seems to be the build result.


If I now try to build druntime it also fails, because the path 
"generated" does not exist:


---
..\dmd\generated\windows\release\32\dmd -conf= -c -o- -Isrc 
-Iimport -Hfimport\core\sync\barrier.di src\core\sync\barrier.d

Error: '..\dmd\generated\windows\release\32\dmd' not found
---

Kind regards
André


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 "
}
```

[0] https://jsonlint.com/


I don't see an unescape function in phobos and below doesn't 
seem to work


string msg2 = 
parseJSON(msg)["markdown"].to!string.replace("\n", " ");


I used replace("\\n", "\n")


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 function in phobos and below doesn't seem 
to work


string msg2 = parseJSON(msg)["markdown"].to!string.replace("\n", 
" ");


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't understand json. A search 
reveals that this is a common mistake.


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() {
 string data =
"This is a paragraph
with line breaks
that shouldn't appear
when the file is loaded
in a text editor.";
   string msg = JSONValue(["markdown": data]).toString;
   string msg2 = parseJSON(msg)["markdown"].to!string;
   writeln(data);
   writeln(msg2);
}

Output:

This is a paragraph
with line breaks
that shouldn't appear
when the file is loaded
in a text editor.
"This is a paragraph\nwith line breaks\nthat shouldn't appear\nwhen the 
file is loaded\nin a text editor."


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/


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 line breaks
that shouldn't appear
when the file is loaded
in a text editor.";
  string msg = JSONValue(["markdown": data]).toString;
  string msg2 = parseJSON(msg)["markdown"].to!string;
  writeln(data);
  writeln(msg2);
}

Output:

This is a paragraph
with line breaks
that shouldn't appear
when the file is loaded
in a text editor.
"This is a paragraph\nwith line breaks\nthat shouldn't 
appear\nwhen the file is loaded\nin a text editor."


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 override int x() { return 0; }
> }
>
> void main() {}
>
> I get the following message:
>
> onlineapp.d(9): Error: function `onlineapp.B.x` package method is
> not virtual and cannot override
> onlineapp.d(10): Error: function `onlineapp.B.x` package method
> is not virtual and cannot override
>
> Why is that? If the access specifier is private, I can perfectly
> understand it - subclasses can't call the private method of
> parent class, so there's no need in making it virtual. For
> protected/public the code compiles. However, for the package
> protection it may happen that a subclass is in the same package
> (and just happened to me).
>
> Should I file a bug or is there a reason for such behavior?

I don't rememeber the reasoning at the moment, but it's most definitely not
a bug and is on purpose. There's probably a "won't fix" bug in bugzilla for
it if you go digging.

- Jonathan M Davis



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` which is also scoped inside a unittest?


I'm guessing T is a POD, so it doesn't need a context pointer, 
whereas S is not counted as a POD since a member function was 
@disabled.


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: function `onlineapp.B.x` package method is 
not virtual and cannot override
onlineapp.d(10): Error: function `onlineapp.B.x` package method 
is not virtual and cannot override


Why is that? If the access specifier is private, I can perfectly 
understand it - subclasses can't call the private method of 
parent class, so there's no need in making it virtual. For 
protected/public the code compiles. However, for the package 
protection it may happen that a subclass is in the same package 
(and just happened to me).


Should I file a bug or is there a reason for such behavior?


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\windows\bin\..\..\src\phobos
import path[1] = C:\D\dmd2\windows\bin\..\..\src\druntime\import

C:\D\dmd2\sources>


http://suckhoeytecongdong.blogspot.com/2018/05/phong-kham-khoa-huu-tho-lua-ao-co-that.html


Re: `this` and nested structs

2018-05-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 10, 2018 06:31:09 Mike Franklin via Digitalmars-d-learn 
wrote:
> On Thursday, 10 May 2018 at 06:22:37 UTC, Jonathan M Davis wrote:
> > Structs don't have that.
>
> Should they?

Honestly, I don't think that classes should have it, but changing it now
would break code (most notably, DWT). IMHO, it would have been far better to
make it explicit like it is in C++, especially since there's no technical
reason why it needs to be built in.

But regardless, when you consider how structs work, having a nested struct
inside a struct have a pointer to its outer struct would be a serious
problem, because the pointer would become invalid as soon as the struct was
moved, which happens quite frequently with structs in D when they're passed
around. Having a nested struct within a class have a reference to its parent
would be more debatable, but it would probably run afoul of how init works,
since the init value for the struct would have to be known at compile-time,
whereas the reference for the class couldn't be. And anyone who wants any
kind of reference to the outer class to be in the struct can just pass it to
the struct's constructor. Adding such a feature to structs would just be
unnecessary magic.

- Jonathan M Davis



Re: `this` and nested structs

2018-05-10 Thread Mike Franklin via Digitalmars-d-learn

On Thursday, 10 May 2018 at 06:22:37 UTC, Jonathan M Davis wrote:


Structs don't have that.


Should they?




Re: `this` and nested structs

2018-05-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 10, 2018 03:23:50 Mike Franklin via Digitalmars-d-learn 
wrote:
> My understanding is that nested structs have an implicit context
> pointer to their containing scope.

A non-static struct inside a function does, but I suspect that you're
thinking about non-static nested classes (within classes), which I believe
was done to be compatible with Java (in order to make porting code easier).
Structs don't have that.

- Jonathan M Davis