Re: Hiding types

2014-05-31 Thread Philippe Sigaud via Digitalmars-d-learn
>> What do you mean? Like this? >> >> Hidden* foo() { return new Hidden();} > > Yes, this way you can control all aspects of the construction and use. You > wouldn't need to make it private even, just don't lay out the struct in the > normal import: > > struct Hidden; > > I think you would need to

Re: Hiding types

2014-05-31 Thread Philippe Sigaud via Digitalmars-d-learn
On Sat, May 31, 2014 at 6:39 AM, Dicebot via Digitalmars-d-learn wrote: > private in D does not provide any strong guarantees, it only controls direct > access to the symbol. You effectively want some sort of strict internal > linkage attribute which does not exist in D. Indeed. I will learn to u

Re: Hiding types

2014-05-30 Thread Dicebot via Digitalmars-d-learn
private in D does not provide any strong guarantees, it only controls direct access to the symbol. You effectively want some sort of strict internal linkage attribute which does not exist in D.

Re: Hiding types

2014-05-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 30 May 2014 16:09:59 -0400, Philippe Sigaud wrote: On Friday, 30 May 2014 at 20:02:40 UTC, Steven Schveighoffer wrote: If you want an opaque struct, you need to return it by pointer. What do you mean? Like this? Hidden* foo() { return new Hidden();} ? Yes, this way you can con

Re: Hiding types

2014-05-30 Thread bearophile via Digitalmars-d-learn
Philippe Sigaud: as foo is returning a value from a private type, it should be considered private also. I think this was discussed, but I don't know why Walter didn't design like that. Perhaps someone else can give you an answer. Bye, bearophile

Re: Hiding types

2014-05-30 Thread Philippe Sigaud via Digitalmars-d-learn
On Friday, 30 May 2014 at 20:02:40 UTC, Steven Schveighoffer wrote: If you want an opaque struct, you need to return it by pointer. What do you mean? Like this? Hidden* foo() { return new Hidden();} ? Otherwise, the user must be able to know what type it is (otherwise, how would he use it

Re: Hiding types

2014-05-30 Thread safety0ff via Digitalmars-d-learn
On Friday, 30 May 2014 at 19:54:00 UTC, safety0ff wrote: On Friday, 30 May 2014 at 19:50:43 UTC, Philippe Sigaud wrote: Am I misunderstanding something or is that a bug? Try: auto foo() { return Hidden();} This is incorrect, please ignore.

Re: Hiding types

2014-05-30 Thread Philippe Sigaud via Digitalmars-d-learn
On Friday, 30 May 2014 at 19:54:00 UTC, safety0ff wrote: On Friday, 30 May 2014 at 19:50:43 UTC, Philippe Sigaud wrote: Am I misunderstanding something or is that a bug? Try: auto foo() { return Hidden();} I'm not seeing any difference? I'm still able to create a value of type Hidden in an

Re: Hiding types

2014-05-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 30 May 2014 15:50:41 -0400, Philippe Sigaud wrote: I'm trying to 'hide' a type, so as not to see it outside its module. I want to control the way it's created and used. I know of Voldemort types and '@disable this', but for now I'm just trying to use 'private'. Halas, it seems it

Re: Hiding types

2014-05-30 Thread safety0ff via Digitalmars-d-learn
On Friday, 30 May 2014 at 19:50:43 UTC, Philippe Sigaud wrote: Am I misunderstanding something or is that a bug? Try: auto foo() { return Hidden();}

Hiding types

2014-05-30 Thread Philippe Sigaud via Digitalmars-d-learn
I'm trying to 'hide' a type, so as not to see it outside its module. I want to control the way it's created and used. I know of Voldemort types and '@disable this', but for now I'm just trying to use 'private'. Halas, it seems it can be circumvented: * module A; private struct Hidd