Re: getting member functions of a struct and Error: identifier expected following ., not this

2018-01-23 Thread thedeemon via Digitalmars-d-learn
On Tuesday, 23 January 2018 at 00:00:38 UTC, aliak wrote: Hi, I'm trying to get a list of only member functions of a struct. I've found that if you do not declare a struct as static inside a scope, then there's a hidden "this" member as part of the struct. Can someone explain the logic there?

Re: static weirdness

2018-01-23 Thread Alex via Digitalmars-d-learn
On Wednesday, 24 January 2018 at 02:01:54 UTC, Jonathan M Davis wrote: On Wednesday, January 24, 2018 01:48:45 Alex via Digitalmars-d-learn wrote: the story of https://forum.dlang.org/thread/qknxjxzbaowmsjdng...@forum.dlang.org continues How can this be? void main() { auto s = S();

Re: static weirdness

2018-01-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 24, 2018 01:48:45 Alex via Digitalmars-d-learn wrote: > the story of > https://forum.dlang.org/thread/qknxjxzbaowmsjdng...@forum.dlang.org > continues > > How can this be? > > void main() > { > auto s = S(); > auto t = T!s(); > assert(typeof(t).dummy == null);

Re: static weirdness

2018-01-23 Thread Alex via Digitalmars-d-learn
On Wednesday, 24 January 2018 at 01:48:45 UTC, Alex wrote: Ah... I figured it out. For using the function of S, an object does not have to exist... And in case I would return a member from S, there is a segmentation violation, as expected. So, everything is ok. Sorry for noise.

static weirdness

2018-01-23 Thread Alex via Digitalmars-d-learn
the story of https://forum.dlang.org/thread/qknxjxzbaowmsjdng...@forum.dlang.org continues How can this be? void main() { auto s = S(); auto t = T!s(); assert(typeof(t).dummy == null); assert(t.dummy == null); t.foo; } struct S { auto fun() { return 42;

Re: static function and access frame

2018-01-23 Thread Alex via Digitalmars-d-learn
On Tuesday, 23 January 2018 at 23:22:09 UTC, Steven Schveighoffer wrote: So, if change the fun to static, it cannot pickup the pointer and therefore can't call anything of the aliased object. If I get it right... I think so. But this is a guess, as the generated call clearly never uses

Re: static function and access frame

2018-01-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/23/18 6:08 PM, Alex wrote: On Tuesday, 23 January 2018 at 22:59:31 UTC, Steven Schveighoffer wrote: On 1/23/18 5:52 PM, Steven Schveighoffer wrote: I don't know the reason. You would think that accessing s would be relative to T.fun's stack frame, and have nothing to do with an instance

Re: static function and access frame

2018-01-23 Thread Alex via Digitalmars-d-learn
On Tuesday, 23 January 2018 at 22:59:31 UTC, Steven Schveighoffer wrote: On 1/23/18 5:52 PM, Steven Schveighoffer wrote: I don't know the reason. You would think that accessing s would be relative to T.fun's stack frame, and have nothing to do with an instance of T. using -vcg-ast gives a

Re: static function and access frame

2018-01-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/23/18 5:52 PM, Steven Schveighoffer wrote: I don't know the reason. You would think that accessing s would be relative to T.fun's stack frame, and have nothing to do with an instance of T. using -vcg-ast gives a hint: https://run.dlang.io/is/MZHPTY Note that the T!(s) struct has a

Re: static function and access frame

2018-01-23 Thread Alex via Digitalmars-d-learn
On Tuesday, 23 January 2018 at 22:52:47 UTC, Steven Schveighoffer wrote: No: void main() { auto s = S(); auto t = T!s(); t.fun; } struct S { void fun(){} } struct T(alias s){ static fun() { s.fun; } } Fails in 2.078. I don't know the reason. You would think that accessing s would

Re: static function and access frame

2018-01-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/23/18 5:33 PM, Ali Çehreli wrote: On 01/23/2018 01:51 PM, Alex wrote: > Ok, I'm quite sure, I overlooked something. > > First version, working > > [code] > void main() > { >  auto s = S(); >  auto t = T!s(); >  t.fun; > } > struct S { void fun(){} } > struct T(alias

Re: static function and access frame

2018-01-23 Thread Alex via Digitalmars-d-learn
On Tuesday, 23 January 2018 at 22:33:31 UTC, Ali Çehreli wrote: On 01/23/2018 01:51 PM, Alex wrote: > Ok, I'm quite sure, I overlooked something. > > First version, working > > [code] > void main() > { > auto s = S(); > auto t = T!s(); > t.fun; > } > struct S { void fun(){} } >

Re: static function and access frame

2018-01-23 Thread Ali Çehreli via Digitalmars-d-learn
On 01/23/2018 01:51 PM, Alex wrote: > Ok, I'm quite sure, I overlooked something. > > First version, working > > [code] > void main() > { > auto s = S(); > auto t = T!s(); > t.fun; > } > struct S { void fun(){} } > struct T(alias s){ auto fun() { s.fun; } } > [/code] > > Now, the

static function and access frame

2018-01-23 Thread Alex via Digitalmars-d-learn
Ok, I'm quite sure, I overlooked something. First version, working [code] void main() { auto s = S(); auto t = T!s(); t.fun; } struct S { void fun(){} } struct T(alias s){ auto fun() { s.fun; } } [/code] Now, the fun method of struct T has to become static and the

Re: [dlang library documentation] Why there are dlang.org/library and dlang.org/phobos?

2018-01-23 Thread Seb via Digitalmars-d-learn
On Monday, 22 January 2018 at 19:38:45 UTC, John Gabriele wrote: On Monday, 22 January 2018 at 15:32:29 UTC, Adam D. Ruppe wrote: On Monday, 22 January 2018 at 15:18:38 UTC, Johann wrote: Maybe it's due to historical reasons. It's actually "future" reasons... the /phobos is the original