Re: Why is this legal?

2017-03-29 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: http://www.gotw.ca/public

Re: Memory Allocation

2017-03-29 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Mar 29, 2017 at 11:01:12PM +, Enigma via Digitalmars-d-learn wrote: > On Wednesday, 29 March 2017 at 21:36:14 UTC, Petar Kirov [ZombineDev] wrote: > > On Wednesday, 29 March 2017 at 19:19:48 UTC, Enigma wrote: > > > [...] > > > > It looks like you are looking for this: > > http://dlang

Re: Memory Allocation

2017-03-29 Thread Enigma via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 21:36:14 UTC, Petar Kirov [ZombineDev] wrote: On Wednesday, 29 March 2017 at 19:19:48 UTC, Enigma wrote: [...] It looks like you are looking for this: http://dlang.org/phobos-prerelease/std_experimental_allocator_building_blocks_region.html. But these seem to

Re: Memory Allocation

2017-03-29 Thread via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 19:19:48 UTC, Enigma wrote: I have a memory buffer allocated using different methods. It is simply a pointer and a size. I would like to be able to manage this buffer by treating it as a memory pool or heap. I think I can use allocators to do this but not sure h

Re: Memory Allocation

2017-03-29 Thread Faux Amis via Digitalmars-d-learn
On 2017-03-29 23:30, Faux Amis wrote: On 2017-03-29 21:19, Enigma wrote: I have a memory buffer allocated using different methods. It is simply a pointer and a size. Can you maybe just tread it like an array and slice it for allocation? *treat*

Re: Memory Allocation

2017-03-29 Thread Faux Amis via Digitalmars-d-learn
On 2017-03-29 21:19, Enigma wrote: I have a memory buffer allocated using different methods. It is simply a pointer and a size. Can you maybe just tread it like an array and slice it for allocation?

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

Memory Allocation

2017-03-29 Thread Enigma via Digitalmars-d-learn
I have a memory buffer allocated using different methods. It is simply a pointer and a size. I would like to be able to manage this buffer by treating it as a memory pool or heap. I think I can use allocators to do this but not sure how. Effectively I want something like new or malloc but it

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 implem

Re: What is the state of scope function parameter?

2017-03-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 05:15:33 UTC, Ali Çehreli wrote: scope: references in the parameter cannot be escaped (e.g. assigned to a global variable). Ignored for parameters with no references However, it doesn't behave that way. For example, my example here currently is

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: What is the state of scope function parameter?

2017-03-29 Thread via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 05:15:33 UTC, Ali Çehreli wrote: [..] How would you change the text there? scope: references in the parameter cannot be escaped (e.g. assigned to a global variable) in @safe code when compiled with -dip1000. Ignored for parameters with no referenc

Re: What is the state of scope function parameter?

2017-03-29 Thread via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 05:15:33 UTC, Ali Çehreli wrote: (More correctly, "scope storage class".) https://dlang.org/spec/function.html#Parameter still says scope: references in the parameter cannot be escaped (e.g. assigned to a global variable). Ignored for parame

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 t

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 actua

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 implem

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 ear

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() { > > > > au

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 "p

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?

Re: C++ namespace mangling: bug or me being stupid?

2017-03-29 Thread Atila Neves via Digitalmars-d-learn
On Tuesday, 28 March 2017 at 16:30:19 UTC, kinke wrote: That's a mangling compression scheme (possibly tunable via gcc options), from https://github.com/gchatelet/gcc_cpp_mangling_documentation: To save space a compression scheme is used where symbols that appears multiple times are then substi

Re: What is the state of scope function parameter?

2017-03-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 28, 2017 22:15:33 Ali Çehreli via Digitalmars-d-learn wrote: > (More correctly, "scope storage class".) > >https://dlang.org/spec/function.html#Parameter > > still says > >scope: references in the parameter cannot be escaped > (e.g. assigned to a global variable