On Sat, 10 Sep 2011 17:06:44 -0400, Andrej Mitrovic
andrej.mitrov...@gmail.com wrote:
On 9/10/11, bearophile bearophileh...@lycos.com wrote:
Andrej Mitrovic Wrote:
Wait a minute, I've just realized private on a class definition has no
effect. Why is that?
Try to import that class from
Andrej Mitrovic Wrote:
Wait a minute, I've just realized private on a class definition has no
effect. Why is that?
Try to import that class from another module...
Bye,
bearophile
Try to import that class from another module...
I fear this is a D design mistake/corner case. If you add tags to a
class/struct definition it usually gets applied to all its methods, but here it
works on the class/struct name itself.
Bye,
bearophile
On Saturday, September 10, 2011 05:20:51 bearophile wrote:
Try to import that class from another module...
I fear this is a D design mistake/corner case. If you add tags to a
class/struct definition it usually gets applied to all its methods, but
here it works on the class/struct name
On 9/10/11, bearophile bearophileh...@lycos.com wrote:
Andrej Mitrovic Wrote:
Wait a minute, I've just realized private on a class definition has no
effect. Why is that?
Try to import that class from another module...
It doesn't stop imports, that's what I'm saying. I can import and
foo\bar.d:
module foo.bar;
private class Foo {}
main.d:
import foo.bar : Foo;
void main()
{
auto foo = new Foo();
}
This should be a compile error, no?
Ok it seems using const works, so I can use that instead. Still I'm
wondering why I can't initialize foo inside a module ctor.
Andrej Mitrovic:
I need to have an object which is initialized only once, so I thought
I could use immutable for that. But I can't do this:
private class Foo {}
immutable Foo foo;
static this()
{
foo = new Foo;
}
void main() {}
private class Foo {}
immutable Foo foo1;
static
On 9/9/11, bearophile bearophileh...@lycos.com wrote:
private class Foo {}
immutable Foo foo1;
static this() {
foo1 = new immutable(Foo);
}
Oh right, that's the syntax. Thanks!
On Friday, September 09, 2011 17:37:26 bearophile wrote:
Andrej Mitrovic:
I need to have an object which is initialized only once, so I thought
I could use immutable for that. But I can't do this:
private class Foo {}
immutable Foo foo;
static this()
{
foo = new Foo;
On 09/09/2011 11:42 PM, Jonathan M Davis wrote:
On Friday, September 09, 2011 17:37:26 bearophile wrote:
Andrej Mitrovic:
I need to have an object which is initialized only once, so I thought
I could use immutable for that. But I can't do this:
private class Foo {}
immutable Foo foo;
static
So much for that idea, immutable breaks property functions. Take a look:
class Foo
{
this()
{
value = true;
}
@property bool value() { return true; }
@property void value(bool value) { }
}
void main()
{
auto foo1 = new Foo;
auto val1 = foo1.value;
auto
For crying out loud, shared fails too:
class Foo
{
shared this()
{
value = true;
}
@property bool value() { return true; }
@property void value(bool value) { }
}
void main()
{
auto foo1 = new Foo;
auto val1 = foo1.value; // fail
}
On 9/9/11 11:45 PM, Andrej Mitrovic wrote:
So much for that idea, immutable breaks property functions. Take a look:
class Foo
{
this()
{
value = true;
}
@property bool value() { return true; }
@property void value(bool value) { }
}
void main()
{
auto
On Friday, September 09, 2011 23:44:10 Timon Gehr wrote:
On 09/09/2011 11:42 PM, Jonathan M Davis wrote:
On Friday, September 09, 2011 17:37:26 bearophile wrote:
Andrej Mitrovic:
I need to have an object which is initialized only once, so I
thought
I could use immutable for that. But I
Ok so this is much more involved than I thought. I need to re-read
parts of TDPL again. Sorry for the excessive noise. :p
16 matches
Mail list logo