Re: (Noob question) Should subclasses be defined in separate modules?

2023-01-12 Thread Mike Parker via Digitalmars-d-learn
On Friday, 13 January 2023 at 05:17:59 UTC, thebluepandabear wrote: (Sorry if this is a duplicate.) If I have the following code inside of a module: ```D class Obj { private { string name = "Hi"; } } class ObjDerived : Obj { } ``` Is it best practice to define `ObjDerived` in

(Noob question) Should subclasses be defined in separate modules?

2023-01-12 Thread thebluepandabear via Digitalmars-d-learn
(Sorry if this is a duplicate.) If I have the following code inside of a module: ```D class Obj { private { string name = "Hi"; } } class ObjDerived : Obj { } ``` Is it best practice to define `ObjDerived` inside another module, since `ObjDerived` can still access the members

Re: Noob question about structs allocation

2018-10-15 Thread Mike Parker via Digitalmars-d-learn
On Monday, 15 October 2018 at 04:14:24 UTC, IM wrote: What is the effect of calling destroy? - calling the destructor? - deallocating the memory? - both? It calls the destructor. The GC will deallocate the object's memory later. However, you need to be careful about how you use GC-allocated

Re: Noob question about structs allocation

2018-10-15 Thread Laurent Tréguier via Digitalmars-d-learn
On Monday, 15 October 2018 at 04:14:24 UTC, IM wrote: What is the effect of calling destroy? - calling the destructor? - deallocating the memory? - both? IIRC, it only calls the destructor, the GC will decide when to deallocate the memory.

Re: Noob question about structs allocation

2018-10-14 Thread IM via Digitalmars-d-learn
On Monday, 15 October 2018 at 03:33:04 UTC, Basile B. wrote: On Monday, 15 October 2018 at 03:19:07 UTC, IM wrote: I probably used to know the answer to this question, but it's been a long time since I last used D, and I don't remember. Suppose we have: struct S { int num; } Would allocati

Re: Noob question about structs allocation

2018-10-14 Thread Basile B. via Digitalmars-d-learn
On Monday, 15 October 2018 at 03:19:07 UTC, IM wrote: I probably used to know the answer to this question, but it's been a long time since I last used D, and I don't remember. Suppose we have: struct S { int num; } Would allocating an instance on the heap using: S* s = new S; use the GC,

Noob question about structs allocation

2018-10-14 Thread IM via Digitalmars-d-learn
I probably used to know the answer to this question, but it's been a long time since I last used D, and I don't remember. Suppose we have: struct S { int num; } Would allocating an instance on the heap using: S* s = new S; use the GC, or do we have to call destroy() or delete on s ourselv

Re: Really nooB question - @property

2014-07-21 Thread Danyal Zia via Digitalmars-d-learn
On Sunday, 20 July 2014 at 16:35:52 UTC, Eric wrote: There are a lot of discussions in the forums about how @property should or could be implemented. But I can't seem to find anything that explains why or when I should use @property with the current compiler. Can anyone explain why and when I

Re: Really nooB question - @property

2014-07-21 Thread Kagamin via Digitalmars-d-learn
On Sunday, 20 July 2014 at 18:14:29 UTC, Eric wrote: Use @property when you want a pseudo-variable or something that might be conceptually considered a "property" of the object, i.e. to do this: auto blah = thing.someProperty; thing.someProperty = blahblah; This is basically what I suspec

Re: Really nooB question - @property

2014-07-21 Thread John Colvin via Digitalmars-d-learn
On Sunday, 20 July 2014 at 18:14:29 UTC, Eric wrote: Use @property when you want a pseudo-variable or something that might be conceptually considered a "property" of the object, i.e. to do this: auto blah = thing.someProperty; thing.someProperty = blahblah; This is basically what I suspec

Re: Really nooB question - @property

2014-07-21 Thread Mike Parker via Digitalmars-d-learn
On 7/21/2014 3:14 AM, Eric wrote: Use @property when you want a pseudo-variable or something that might be conceptually considered a "property" of the object, i.e. to do this: auto blah = thing.someProperty; thing.someProperty = blahblah; This is basically what I suspected. But why write:

Re: Really nooB question - @property

2014-07-21 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 20 July 2014 at 16:35:52 UTC, Eric wrote: There are a lot of discussions in the forums about how @property should or could be implemented. But I can't seem to find anything that explains why or when I should use @property with the current compiler. Can anyone explain why and when

Re: Really nooB question - @property

2014-07-21 Thread Ali Çehreli via Digitalmars-d-learn
On 07/20/2014 11:14 AM, Eric wrote: > >> Use @property when you want a pseudo-variable or something that might >> be conceptually considered a "property" of the object, i.e. to do this: >> >> auto blah = thing.someProperty; >> thing.someProperty = blahblah; > > This is basically what I suspected.

Re: Really nooB question - @property

2014-07-21 Thread John Colvin via Digitalmars-d-learn
On Sunday, 20 July 2014 at 16:35:52 UTC, Eric wrote: There are a lot of discussions in the forums about how @property should or could be implemented. But I can't seem to find anything that explains why or when I should use @property with the current compiler. Can anyone explain why and when

Re: Really nooB question - @property

2014-07-21 Thread John Colvin via Digitalmars-d-learn
On Sunday, 20 July 2014 at 17:59:07 UTC, John Colvin wrote: On Sunday, 20 July 2014 at 16:35:52 UTC, Eric wrote: There are a lot of discussions in the forums about how @property should or could be implemented. But I can't seem to find anything that explains why or when I should use @property

Re: Really nooB question - @property

2014-07-21 Thread Eric via Digitalmars-d-learn
Use @property when you want a pseudo-variable or something that might be conceptually considered a "property" of the object, i.e. to do this: auto blah = thing.someProperty; thing.someProperty = blahblah; This is basically what I suspected. But why write: @property int getValue() { retur

Really nooB question - @property

2014-07-21 Thread Eric via Digitalmars-d-learn
There are a lot of discussions in the forums about how @property should or could be implemented. But I can't seem to find anything that explains why or when I should use @property with the current compiler. Can anyone explain why and when I should use the @property tag? Thx. Eric

Re: noob question

2009-08-07 Thread llltattoolll
thx sergey my example work correctly now :D

Re: noob question

2009-08-06 Thread Sergey Gromov
Thu, 06 Aug 2009 10:56:33 -0400, lllTattoolll wrote: > hi Lars and thx for help. I fix a little the first problem, now I paste a > verion in english whit coment because i´m lost here. > the example is the same only this is in english for your compresion of my > problem. > >

Re: noob question

2009-08-06 Thread BCS
Reply to llltattoolll, writefln ("Your age is %d? \t YES \t NO", _age ); /* here is my second problem, can´t into the response and program*/ _response = readln(); /* show me else line always */ // if all else fails, what are you getting writef(">>%s<<\n", cast(ubyte[])chomp(_response));

Re: noob question

2009-08-06 Thread lllTattoolll
hi Lars and thx for help. I fix a little the first problem, now I paste a verion in english whit coment because i´m lost here. the example is the same only this is in english for your compresion of my problem. -- code --

Re: noob question

2009-08-06 Thread Lars T. Kyllingstad
Lars T. Kyllingstad wrote: llltattoolll wrote: hi im noob here and try learn D language, i try make this example but when run have 2 problems. 1) when i show name and lastname show me in two lines and i wanna make in the same line. 2) can´t validate option si ( yes ) or no ( no ) and always s

Re: noob question

2009-08-06 Thread Lars T. Kyllingstad
llltattoolll wrote: hi im noob here and try learn D language, i try make this example but when run have 2 problems. 1) when i show name and lastname show me in two lines and i wanna make in the same line. 2) can´t validate option si ( yes ) or no ( no ) and always show the else line. what hap

noob question

2009-08-06 Thread llltattoolll
hi im noob here and try learn D language, i try make this example but when run have 2 problems. 1) when i show name and lastname show me in two lines and i wanna make in the same line. 2) can´t validate option si ( yes ) or no ( no ) and always show the else line. what happend? thx ---