Re: Why is this legal?

2017-03-30 Thread bauss via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 10:08:02 UTC, abad wrote: Related question, it seems that final methods are allowed in interfaces. Obviously you can't implement them anywhere, so is this also on purpose and on what rationale? :) That is not necessarily true. Final doesn't imply it can't be

Re: Why is this legal?

2017-03-30 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 09:50:10 UTC, abad wrote: Is this on purpose and what's the rationale? In Andrei's book, chapter 6.9.1 "the non virtual interface (NVI) idiom" answers your question. It cites this article by Herb Sutter as the originator of the idea:

Re: Why is this legal?

2017-03-29 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Mar 29, 2017 at 11:24:04AM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > On Wednesday, March 29, 2017 10:08:02 abad via Digitalmars-d-learn wrote: > > Related question, it seems that final methods are allowed in > > interfaces. Obviously you can't implement them anywhere, so is

Re: Why is this legal?

2017-03-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 29, 2017 10:08:02 abad via Digitalmars-d-learn wrote: > Related question, it seems that final methods are allowed in > interfaces. Obviously you can't implement them anywhere, so is > this also on purpose and on what rationale? :) If the function is final, it can have an

Re: Why is this legal?

2017-03-29 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 11:17:48 UTC, abad wrote: Yes, does make sense. I was looking this from Java 7 perspective where interfaces can't implement any methods. D did not support them either for much of its history. IIRC, we got them at some point after Java did.

Re: Why is this legal?

2017-03-29 Thread abad via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 11:06:55 UTC, Petar Kirov [ZombineDev] wrote: On Wednesday, 29 March 2017 at 10:12:08 UTC, abad wrote: On Wednesday, 29 March 2017 at 10:08:02 UTC, abad wrote: Related question, it seems that final methods are allowed in interfaces. Obviously you can't implement

Re: Why is this legal?

2017-03-29 Thread via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 10:12:08 UTC, abad wrote: On Wednesday, 29 March 2017 at 10:08:02 UTC, abad wrote: Related question, it seems that final methods are allowed in interfaces. Obviously you can't implement them anywhere, so is this also on purpose and on what rationale? :) So

Re: Why is this legal?

2017-03-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 29, 2017 10:08:02 abad via Digitalmars-d-learn wrote: > Related question, it seems that final methods are allowed in > interfaces. Obviously you can't implement them anywhere, so is > this also on purpose and on what rationale? :) If the function is final, it can have an

Re: Why is this legal?

2017-03-29 Thread abad via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 10:08:02 UTC, abad wrote: Related question, it seems that final methods are allowed in interfaces. Obviously you can't implement them anywhere, so is this also on purpose and on what rationale? :) So actually it's just a question of not catching this mistake

Re: Why is this legal?

2017-03-29 Thread abad via Digitalmars-d-learn
Related question, it seems that final methods are allowed in interfaces. Obviously you can't implement them anywhere, so is this also on purpose and on what rationale? :)

Re: Why is this legal?

2017-03-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 29, 2017 10:56:34 rikki cattermole via Digitalmars-d- learn wrote: > On 29/03/2017 10:50 AM, abad wrote: > > This works: > > > > class Foo { > > > > protected void bar() { > > > > writeln("hello from foo"); > > > > } > > > > } > > > > void main() { > > > >

Re: Why is this legal?

2017-03-29 Thread abad via Digitalmars-d-learn
Never mind, it's working OK if the class is defined in another module.

Re: Why is this legal?

2017-03-29 Thread rikki cattermole via Digitalmars-d-learn
On 29/03/2017 10:50 AM, abad wrote: This works: class Foo { protected void bar() { writeln("hello from foo"); } } void main() { auto foo = new Foo; foo.bar(); } Is this on purpose and what's the rationale? http://dlang.org/spec/attribute.html#visibility_attributes

Why is this legal?

2017-03-29 Thread abad via Digitalmars-d-learn
This works: class Foo { protected void bar() { writeln("hello from foo"); } } void main() { auto foo = new Foo; foo.bar(); } Is this on purpose and what's the rationale?