Re: Time for std.reflection

2012-11-19 Thread Malte Skarupke
I like it. First a couple details: class ClassInfo { @property: string name(); string baseName(); string parentName(); // if applicable, null otherwise string[] interfaces(); bool isShared(); Protection protection(); DataMemberInfo[] data(); MethodInfo[]

Re: How do you remove/insert elements in a dynamic array without allocating?

2012-11-08 Thread Malte Skarupke
On Wednesday, 7 November 2012 at 09:45:48 UTC, monarch_dodra wrote: On Wednesday, 7 November 2012 at 03:45:06 UTC, Malte Skarupke wrote: Having no clear ownership for the array is not something I am willing to accept. Strong ownership puts you back into C++'s boat of bordering psychotic

Re: How do you remove/insert elements in a dynamic array without allocating?

2012-11-06 Thread Malte Skarupke
On Tuesday, 6 November 2012 at 09:10:08 UTC, bearophile wrote: Malte Skarupke: I will most certainly never use dynamic arrays or slices again for anything that needs to grow or shrink dynamically. And doing so you will miss an important and handy part of D :-/ Bye, bearophile I

How do you remove/insert elements in a dynamic array without allocating

2012-11-05 Thread Malte Skarupke
Let's say I want to

How do you remove/insert elements in a dynamic array without allocating?

2012-11-05 Thread Malte Skarupke
Following code: void main() { import core.memory; GC.disable(); scope(exit) GC.enable(); int[] a = [1, 2, 3, 4, 5]; foreach(i; 0 .. 10) { --a.length; a ~= i; } } That loop will keep on allocating in every iteration until your memory is full.

Re: How do you remove/insert elements in a dynamic array without allocating?

2012-11-05 Thread Malte Skarupke
On Tuesday, 6 November 2012 at 01:25:39 UTC, Jonathan M Davis wrote: On Tuesday, November 06, 2012 02:11:06 Malte Skarupke wrote: Following code: void main() { import core.memory; GC.disable(); scope(exit) GC.enable(); int[] a = [1, 2, 3, 4, 5]; foreach(i; 0 .. 10) { --a.length

Re: Const ref and rvalues again...

2012-11-04 Thread Malte Skarupke
On Monday, 5 November 2012 at 03:26:10 UTC, Jonathan M Davis wrote: On Sunday, November 04, 2012 20:43:36 Andrei Alexandrescu wrote: On 11/4/12 7:58 PM, martin wrote: I find it sad that while this topic seems to be of high priority for quite a lot of language users, it is seemingly

Re: D vs C++11

2012-11-03 Thread Malte Skarupke
On Friday, 2 November 2012 at 17:03:38 UTC, Erèbe wrote: Hello student here, I have started to learn D a few months ago with Andrei's book (I really liked arguments about design decisions), but as the same time I was learning new features of C++11, and now I'm really confused. (As learning

Re: D vs C++11

2012-11-03 Thread Malte Skarupke
On Saturday, 3 November 2012 at 22:45:59 UTC, Tommi wrote: On Saturday, 3 November 2012 at 22:01:21 UTC, Malte Skarupke wrote: D also makes the const keyword more annoying than it should be. What kind of annoyances regarding const have you encountered in D? To start off it's simple things

How do you copy a const struct to a mutable?

2012-10-31 Thread Malte Skarupke
I want to get this to compile: void main() { struct A { this(int x) { this.x = x; } int x; } const(A) a = A(5); A b = a; } It should clearly be legal to create a non-const copy of the struct. What am I missing in order to do this? Cheers, Malte

Re: Const ref and rvalues again...

2012-10-20 Thread Malte Skarupke
On Friday, 19 October 2012 at 13:00:52 UTC, Timon Gehr wrote: On 10/19/2012 09:53 AM, Jacob Carlborg wrote: On 2012-10-19 04:48, Timon Gehr wrote: Then how to specify that the value of x cannot be escaped? I'm in favour of doing it the other way round and disallow escaping of ref parameters

Re: Const ref and rvalues again...

2012-10-18 Thread Malte Skarupke
On Thursday, 18 October 2012 at 06:11:26 UTC, monarch_dodra wrote: On Thursday, 18 October 2012 at 04:30:17 UTC, Jonathan M Davis wrote: On Thursday, October 18, 2012 06:24:08 jerro wrote: What would be the problem with const ref taking rvalues? Read the thread that I already linked to:

Re: Const ref and rvalues again...

2012-10-18 Thread Malte Skarupke
On Friday, 19 October 2012 at 00:03:49 UTC, Timon Gehr wrote: Const is different in D and in C++. Relating const and rvalues is arbitrary and does not make a lot of sense. Regarding 'in ref'/'scope ref': What should 'scope' apply to in void foo(scope ref int* x); Not sure what you mean

Re: How mutable is immutable?

2012-10-17 Thread Malte Skarupke
The issue is that you're thinking as you would in Java. I guess the rule in D for immutable is this: Immutable data won't change as long as it exists. The last part of that sentence would be a stupid thing to say in Java because things don't just cease to exist while you're still doing

Const ref and rvalues again...

2012-10-17 Thread Malte Skarupke
Hello, I realize that this has been discussed before, but so far there is no solution and this really needs to be a high priority: We need a way for a function to declare that it doesn't want it's argument to be copied, but it also doesn't care whether the argument is an rvalue or an

Re: What is the case against a struct post-blit default constructor?

2012-10-11 Thread Malte Skarupke
First of all thank you for the detailed responses. I wrote a response yesterday but somehow the website seems to have swallowed it. On Thursday, 11 October 2012 at 12:43:31 UTC, Andrei Alexandrescu wrote: We could (after all, C++ does it). There are a few disadvantages to doing so, however.

Re: What is the case against a struct post-blit default constructor?

2012-10-10 Thread Malte Skarupke
Hi, thanks for the detailed answers. So I am very much for keeping init. I just want that if the user specifies a default constructor, it is being called after the value has been initialized to init. On Wednesday, October 10, 2012 21:11:29 foobar wrote: Arrays - without changing existing

What is the case against a struct post-blit default constructor?

2012-10-08 Thread Malte Skarupke
So this has been brought up many times (http://www.digitalmars.com/d/archives/digitalmars/D/Struct_no-arg_constructor_173172.html http://www.digitalmars.com/d/archives/digitalmars/D/learn/Default_constructor_for_structs_20997.html