Re: static class vs. static struct

2015-11-19 Thread vyarthrot via Digitalmars-d-learn
On Monday, 26 January 2015 at 14:02:54 UTC, ref2401 wrote: What's the difference between static class and static struct? What should i use? In simple words, Singleton is a pattern and not a keyword. The Singleton pattern has several advantages over static classes. A singleton allows a class f

Re: static class vs. static struct

2015-07-15 Thread creiglee via Digitalmars-d-learn
In simple words, Singleton is a pattern and not a keyword. The Singleton pattern has several advantages over static classes. A singleton allows a class for which there is just one, persistent instance across the lifetime of an application. That means, it created a single instance and that insta

Re: static class vs. static struct

2015-01-27 Thread Ali Çehreli via Digitalmars-d-learn
On 01/27/2015 01:33 PM, Piotrek wrote: > On Tuesday, 27 January 2015 at 18:24:29 UTC, Ali Çehreli wrote: >> On 01/27/2015 08:33 AM, Piotrek wrote: >> >> >> Non-static means nested. >> > >> > Hmm,this can be misleading. Nesting in structs doesn't >> introduce context >> > pointer. Oh, I misread w

Re: static class vs. static struct

2015-01-27 Thread Ali Çehreli via Digitalmars-d-learn
On 01/27/2015 01:44 PM, Piotrek wrote: > Let me here thank for your book I am glad that it is useful. > which I've been reading for some time. Me too! I browsed the index section to remember the other uses of 'static'. :) Ali

Re: static class vs. static struct

2015-01-27 Thread Piotrek via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 18:18:02 UTC, Ali Çehreli wrote: On 01/27/2015 08:58 AM, Piotrek wrote: Nice list. :) > 1. static variable > > struct A{int a} // no static before declaration > static A s; //note that static is used for struct variable storage class > (lifetime) > > static int b;

Re: static class vs. static struct

2015-01-27 Thread Piotrek via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 18:24:29 UTC, Ali Çehreli wrote: On 01/27/2015 08:33 AM, Piotrek wrote: >> Non-static means nested. > > Hmm,this can be misleading. Nesting in structs doesn't introduce context > pointer. You must be thinking of structs nested inside user-defined types. Structs t

Re: static class vs. static struct

2015-01-27 Thread Ali Çehreli via Digitalmars-d-learn
On 01/27/2015 08:33 AM, Piotrek wrote: >> Non-static means nested. > > Hmm,this can be misleading. Nesting in structs doesn't introduce context > pointer. You must be thinking of structs nested inside user-defined types. Structs that are nested inside functions do have the context pointer. Al

Re: static class vs. static struct

2015-01-27 Thread Ali Çehreli via Digitalmars-d-learn
On 01/27/2015 08:58 AM, Piotrek wrote: Nice list. :) > 1. static variable > > struct A{int a} // no static before declaration > static A s; //note that static is used for struct variable storage class > (lifetime) > > static int b; > etc. > > 2. static declaration > > static struct A{int a}; //s

Re: static class vs. static struct

2015-01-27 Thread Piotrek via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 09:01:39 UTC, ref2401 wrote: For several times I've met struct(or static struct) usage in Phobos for singleton pattern implementation. Unfortunately now i can remember only core.runtime.Runtime. So I've got a question. Why do Phobos guys use struct or static struc

Re: static class vs. static struct

2015-01-27 Thread Artur Skawina via Digitalmars-d-learn
On 01/27/15 10:40, Daniel Kozak via Digitalmars-d-learn wrote: > On Tuesday, 27 January 2015 at 09:36:49 UTC, Daniel Kozak wrote: >> On Tuesday, 27 January 2015 at 09:01:39 UTC, ref2401 wrote: >>> For several times I've met struct(or static struct) usage in Phobos for >>> singleton pattern impleme

Re: static class vs. static struct

2015-01-27 Thread Piotrek via Digitalmars-d-learn
On Monday, 26 January 2015 at 21:55:19 UTC, anonymous wrote: On Monday, 26 January 2015 at 21:33:10 UTC, Piotrek wrote: On Monday, 26 January 2015 at 14:11:32 UTC, bearophile wrote: Non-static structs/classes have an extra pointer. Bye, bearophile Since when structs have an extra pointer? Ma

Re: static class vs. static struct

2015-01-27 Thread ketmar via Digitalmars-d-learn
On Tue, 27 Jan 2015 09:40:08 +, Daniel Kozak wrote: > import std.stdio; > import std.conv; > > struct S { > @disable this(); > } > > final class C { > } > > void main() { > writeln(C.sizeof); > writeln(S.sizeof); > } blind guess: vmt with "toString()" from Object? ;-) signa

Re: static class vs. static struct

2015-01-27 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 09:36:49 UTC, Daniel Kozak wrote: On Tuesday, 27 January 2015 at 09:01:39 UTC, ref2401 wrote: For several times I've met struct(or static struct) usage in Phobos for singleton pattern implementation. Unfortunately now i can remember only core.runtime.Runtime. So I

Re: static class vs. static struct

2015-01-27 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 09:01:39 UTC, ref2401 wrote: For several times I've met struct(or static struct) usage in Phobos for singleton pattern implementation. Unfortunately now i can remember only core.runtime.Runtime. So I've got a question. Why do Phobos guys use struct or static struc

Re: static class vs. static struct

2015-01-27 Thread ref2401 via Digitalmars-d-learn
For several times I've met struct(or static struct) usage in Phobos for singleton pattern implementation. Unfortunately now i can remember only core.runtime.Runtime. So I've got a question. Why do Phobos guys use struct or static struct for or singleton pattern implementation? Why don't use sta

Re: static class vs. static struct

2015-01-26 Thread anonymous via Digitalmars-d-learn
On Monday, 26 January 2015 at 21:33:10 UTC, Piotrek wrote: On Monday, 26 January 2015 at 14:11:32 UTC, bearophile wrote: Non-static structs/classes have an extra pointer. Bye, bearophile Since when structs have an extra pointer? Maybe you are talking about nested structs? Non-static means

Re: static class vs. static struct

2015-01-26 Thread Piotrek via Digitalmars-d-learn
On Monday, 26 January 2015 at 14:11:32 UTC, bearophile wrote: Non-static structs/classes have an extra pointer. Bye, bearophile Since when structs have an extra pointer? Maybe you are talking about nested structs? Piotrek

Re: static class vs. static struct

2015-01-26 Thread bearophile via Digitalmars-d-learn
On Monday, 26 January 2015 at 14:02:54 UTC, ref2401 wrote: What's the difference between static class and static struct? What should i use? Non-static structs/classes have an extra pointer. Static ones don't have it, so their differences are the usual ones: a class is used by reference and th

static class vs. static struct

2015-01-26 Thread ref2401 via Digitalmars-d-learn
What's the difference between static class and static struct? What should i use?