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
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
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
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
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;
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
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
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
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
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
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
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
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
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
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
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
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
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
C# compilers present bugs with a standard number, like:
myprog.cs(7,60): error CS1525: ...
This is useful because you can then write an explanation page
for each of those bugs, like CS1525:
http://msdn.microsoft.com/en-gb/library/3hdyz4dw%28v=vs.80%29.aspx
In such pages you can explain w
On Tuesday, 11 June 2013 at 16:09:39 UTC, Steven Schveighoffer
wrote:
On Tue, 11 Jun 2013 10:04:21 -0400, Eric
wrote:
The following code does not compile:
class Foo { int x; }
class Bar { static Foo f = new Foo(); } // compiler error
static Foo g = new Foo(); // compiler error
These can
On Tue, 11 Jun 2013 10:04:21 -0400, Eric wrote:
The following code does not compile:
class Foo { int x; }
class Bar { static Foo f = new Foo(); } // compiler error
static Foo g = new Foo(); // compiler error
These can be solved with a static ctor. Essentially, any static
initializers mu
Why aren't static class instances allowed? Is there a
work-around,
or alternative approach to this?
C# compilers present bugs with a standard number, like:
myprog.cs(7,60): error CS1525: ...
This is useful because you can then write an explanation page
for each of those bugs, like CS1
Eric:
The following code does not compile:
class Foo { int x; }
class Bar { static Foo f = new Foo(); } // compiler error
static Foo g = new Foo(); // compiler error
void main() {}
(dmd7) desk3:~/tp/d_test2/dlib>dmd T.d
T.d(4): Error: variable T.Bar.f is mutable. Only const or
immutable clas
On Friday, February 22, 2013 22:12:44 Michael wrote:
> In D a module can be statically imported and then I can use full
> names.
>
> But question: is it possible to force a static import?
No.
- Jonathan M Davis
In D a module can be statically imported and then I can use full
names.
But question: is it possible to force a static import?
On Friday, February 22, 2013 20:39:01 Michael wrote:
> On Friday, 22 February 2013 at 04:06:09 UTC, Jonathan M Davis
>
> wrote:
> >I'm not talking about static. I'm talking about the fact that
> >putting both final and abstract on a class isn't a problem.
> >
> > - Jonathan M Davis
>
> Initial qu
On Friday, 22 February 2013 at 04:06:09 UTC, Jonathan M Davis
wrote:
I'm not talking about static. I'm talking about the fact that
putting both final and abstract on a class isn't a problem.
- Jonathan M Davis
Initial question for me was how to get something like:
They only contain static me
It's natural and would be good if something will be stated in
documentation about static at top-level.
"static" is well known feature. Yes it can act differently in
diff languages.
They're losing their time if they expect D to act as another
language.
With this point of view to user, only
On 2/22/13, Ary Borenszweig wrote:
> Don't you see that as a problem? People loosing their time answering
> this questions over and over again instead of the compiler giving you
> the answer.
They're losing their time if they expect D to act as another language.
Anyway an annoying compiler compl
On Friday, February 22, 2013 00:59:45 Ary Borenszweig wrote:
> On 2/21/13 8:34 PM, Jonathan M Davis wrote:
> > On Friday, February 22, 2013 00:06:26 bearophile wrote:
> >> Jonathan M Davis:
> >>> D doesn't
> >>> bother to check, so you get the natural consequence of mixing
> >>> them. I'm quite
> >
On 2/21/13 8:34 PM, Jonathan M Davis wrote:
On Friday, February 22, 2013 00:06:26 bearophile wrote:
Jonathan M Davis:
D doesn't
bother to check, so you get the natural consequence of mixing
them. I'm quite
sure that the fact that it works that way is an accident. It
was never
intentially made t
On Friday, February 22, 2013 00:06:26 bearophile wrote:
> Jonathan M Davis:
> > D doesn't
> > bother to check, so you get the natural consequence of mixing
> > them. I'm quite
> > sure that the fact that it works that way is an accident. It
> > was never
> > intentially made to be allowed or disall
Jonathan M Davis:
D doesn't
bother to check, so you get the natural consequence of mixing
them. I'm quite
sure that the fact that it works that way is an accident. It
was never
intentially made to be allowed or disallowed. It's just
allowed, because
there's nothing intrinsic about either of t
On Thursday, February 21, 2013 19:52:39 Michael wrote:
> > I'm sure you knew that and it's just a wording thing :)
> >
> > Fun fact: in Java, it's an error to combine 'final' and
> > 'abstract'.
>
> Yes.
> As I understand, in D the "abstract" keyword is some alternative
> to @disable in that case
I'm sure you knew that and it's just a wording thing :)
Fun fact: in Java, it's an error to combine 'final' and
'abstract'.
Yes.
As I understand, in D the "abstract" keyword is some alternative
to @disable in that case.
On 18/02/2013 21:25, Michael wrote:
Yes, it's comes from C#.
So, there is no static for classes at module level. Good to have a msg
for it at compile-time.
import std.stdio;
public final abstract class Test
{
static this() { writeln("in static ctor"); }
static :
void foo() { writ
Yes, it's comes from C#.
So, there is no static for classes at module level. Good to have
a msg for it at compile-time.
import std.stdio;
public final abstract class Test
{
static this() { writeln("in static ctor"); }
static :
void foo() { writeln("in static method"); }
}
void
Am 17.02.2013 23:25, schrieb Jonathan M Davis:
On Sunday, February 17, 2013 23:00:19 Michael wrote:
> That's not the meaning of static in that context.
As I understand a static class can't be instantiated.
I have no idea how you came to that conclusion. That's not what it means for a
class to
On 2/17/13 7:25 PM, Jonathan M Davis wrote:
On Sunday, February 17, 2013 23:00:19 Michael wrote:
That's not the meaning of static in that context.
As I understand a static class can't be instantiated.
I have no idea how you came to that conclusion.
Probably because of this:
http://msdn.mi
On Sunday, 17 February 2013 at 22:26:16 UTC, Jonathan M Davis
wrote:
On Sunday, February 17, 2013 23:00:19 Michael wrote:
> That's not the meaning of static in that context.
As I understand a static class can't be instantiated.
I have no idea how you came to that conclusion. That's not what
On Sun, 17 Feb 2013 18:26:37 -0500, Ben Davis wrote:
On 17/02/2013 22:25, Jonathan M Davis wrote:
On Sunday, February 17, 2013 23:00:19 Michael wrote:
That's not the meaning of static in that context.
As I understand a static class can't be instantiated.
I have no idea how you came to tha
On Sunday, February 17, 2013 23:26:37 Ben Davis wrote:
> On 17/02/2013 22:25, Jonathan M Davis wrote:
> > However, non-static nested classes are associated with an instance of the
> > outer class, and therefore only one can exist per class instance.
>
> That's not true, is it? You can make as many
On 17/02/2013 22:25, Jonathan M Davis wrote:
On Sunday, February 17, 2013 23:00:19 Michael wrote:
That's not the meaning of static in that context.
As I understand a static class can't be instantiated.
I have no idea how you came to that conclusion.
In fairness, it is the natural guess you
On Sunday, February 17, 2013 14:47:12 H. S. Teoh wrote:
> On Sun, Feb 17, 2013 at 11:46:24PM +0100, Andrej Mitrovic wrote:
> > On 2/17/13, Steven Schveighoffer wrote:
> > > A class that can't be instantiated has a private constructor.
> >
> > An alternative to that is:
> >
> > final abstract cla
On Sun, Feb 17, 2013 at 11:46:24PM +0100, Andrej Mitrovic wrote:
> On 2/17/13, Steven Schveighoffer wrote:
> > A class that can't be instantiated has a private constructor.
>
> An alternative to that is:
>
> final abstract class C
> {
> static:
> }
>
> You can't derive from it and you can't
On Sunday, February 17, 2013 23:00:19 Michael wrote:
> > That's not the meaning of static in that context.
>
> As I understand a static class can't be instantiated.
I have no idea how you came to that conclusion. That's not what it means for a
class to be static at all. The only place that stati
On Sun, 17 Feb 2013 17:00:19 -0500, Michael wrote:
That's not the meaning of static in that context.
As I understand a static class can't be instantiated.
Static in that position is a no-op. The compiler (infuriatingly
sometimes) accepts attributes that have no meaning silently.
So i
That's not the meaning of static in that context.
As I understand a static class can't be instantiated.
The above is useful in nested classes.
I just read it. Holy s.. cow.
Instead you can use:
class Test
{
static:
void foo() { }
}
So in mine case if I want purely static class I nee
On 2/17/13, Michael wrote:
> Why members of static class are not implicitly static?
>
> static class Test
> {
> void foo() {}
> }
>
That's not the meaning of static in that context. The above is useful
in nested classes.
Instead you can use:
class Test
{
static:
void foo() { }
}
On Thursday, 14 February 2013 at 12:49:01 UTC, Lubos Pintes wrote:
Hi,
I saw one ListBox class implementation.
As we all know, ListBox class collects and displays strings.
Author decided that he encapsulate the Object as item, and uses
its toString() method when string is needed for display.
Fo
On Thu, 21 Apr 2011 04:54:49 -0400, Mike Parker wrote:
I'm certain this used to work:
class Foo
{
public static
{
void bar() {}
}
}
But I've found that now, anything inside the public static block is not
actually static. I get an error attempting to call Foo.bar(). I
51 matches
Mail list logo