Re: deprecated delete and manual memory management

2011-04-28 Thread Dmitry Olshansky
On 28.04.2011 2:19, Alexander wrote: On 27.04.2011 22:46, Dmitry Olshansky wrote: - there is an awful lot of operations which allocate GC memory implicitly aka arr1 ~ arr2, so it's not like you can pass the allocator and prevent the function from allocating _somewhere_ else This is solvab

Re: deprecated delete and manual memory management

2011-04-28 Thread Jacob Carlborg
On 2011-04-27 20:44, ulrik.mikaels...@gmail.com wrote: Den, skrevJacob Carlborg : > Yeah, that's correct. But in this case I think he actually was referring to the latest commit. I'm pretty sure I've heard the latest commit in SVN be referred to as "trunk". I'm too curious for my own good, so I

Re: std.parallelism is accepted into Phobos

2011-04-28 Thread Jacob Carlborg
On 2011-04-27 21:13, Andrei Alexandrescu wrote: On 4/27/11 1:13 AM, Russel Winder wrote: What also matters is that stuff that stays is stuff that gets done. You seem to have a good amount of expertise, but at the same time choose to firmly plant your figurative self in the proverbial armchair. I

Re: deprecated delete and manual memory management

2011-04-28 Thread Jacob Carlborg
On 2011-04-27 22:28, Daniel Gibson wrote: Am 27.04.2011 22:13, schrieb so: One thing that is perhaps obvious, but eludes me; when dropping the delete-operator, are there any obvious reason to not also drop the "new" keyword? ("new" is a fairly good method/variable name, if nothing else) I could

Re: deprecated delete and manual memory management

2011-04-28 Thread Jacob Carlborg
On 2011-04-28 00:15, Alexander wrote: On 27.04.2011 22:42, Steven Schveighoffer wrote: For non-garbage-collected languages, yes. For GC languages, delete is to be discouraged (that is what the GC is for). delete() is 99% of the cases O(1) operation (thanks to free lists), while invocati

Re: deprecated delete and manual memory management

2011-04-28 Thread Alexander
On 28.04.2011 10:14, Dmitry Olshansky wrote: > That's your C++ experience speaking ;) It seems you just like manual memory > management in c++ and can't see other ways. This is not true, actually :) I agree, that GC is nice thing for most applications, and I really like it, but, I simply wa

Re: How about a Hash template?

2011-04-28 Thread Alexander
On 28.04.2011 01:10, Andrej Mitrovic wrote: > I really like the "in" keyword, and I also like hashes since they can > potentially speed up look-ups compared to conventional arrays. The problem is, "potentially" means "for [relatively] large sets", as hashing overhead will kill the benefits for

Re: deprecated delete and manual memory management

2011-04-28 Thread Daniel Gibson
Am 28.04.2011 10:28, schrieb Jacob Carlborg: On 2011-04-27 22:28, Daniel Gibson wrote: Am 27.04.2011 22:13, schrieb so: One thing that is perhaps obvious, but eludes me; when dropping the delete-operator, are there any obvious reason to not also drop the "new" keyword? ("new" is a fairly good m

Programming language benchmarks

2011-04-28 Thread Moritz Warning
I think this might be interesting; it's also using D. http://attractivechaos.wordpress.com/2011/04/25/my-programming-language- benchmarks-plb/

Re: Programming language benchmarks

2011-04-28 Thread Francisco Almeida
On 28-04-2011 12:57, Moritz Warning wrote: I think this might be interesting; it's also using D. http://attractivechaos.wordpress.com/2011/04/25/my-programming-language- benchmarks-plb/ Oh dear, the regex results for D are dreadful. And the matmul benchmark result isn't too encouraging either

Re: Programming language benchmarks

2011-04-28 Thread Robert Clipsham
On 28/04/2011 11:57, Moritz Warning wrote: I think this might be interesting; it's also using D. http://attractivechaos.wordpress.com/2011/04/25/my-programming-language- benchmarks-plb/ Looks like this is using an old version of gdc along with D1, and it performs abysmally on quite a few of t

Re: Programming language benchmarks

2011-04-28 Thread Robert Clipsham
On 28/04/2011 12:13, Robert Clipsham wrote: On 28/04/2011 11:57, Moritz Warning wrote: I think this might be interesting; it's also using D. http://attractivechaos.wordpress.com/2011/04/25/my-programming-language- benchmarks-plb/ Looks like this is using an old version of gdc along with D1, a

Re: Programming language benchmarks

2011-04-28 Thread Alexander
On 28.04.2011 13:24, Robert Clipsham wrote: > I also notice lots of nested for loops in some of the tests, which should be > using slice operations really. This is the whole point of benchmarking, IMHO - to see how good compiler/optimizer (and VM, if any) are - for (almost) same code, same a

Re: deprecated delete and manual memory management

2011-04-28 Thread Alexander
On 28.04.2011 12:46, Daniel Gibson wrote: > ... so IMHO it makes sense for D to have the same syntax as the majority of > these languages for the same feature (if that syntax doesn't have big enough > drawbacks like <> for templates). That's my point too. And especially this is true when some

Re: Programming language benchmarks

2011-04-28 Thread Robert Clipsham
On 28/04/2011 12:37, Alexander wrote: On 28.04.2011 13:24, Robert Clipsham wrote: I also notice lots of nested for loops in some of the tests, which should be using slice operations really. This is the whole point of benchmarking, IMHO - to see how good compiler/optimizer (and VM, if any

Re: Programming language benchmarks

2011-04-28 Thread bearophile
Moritz Warning: > I think this might be interesting; it's also using D. I was about to post this :-) The little benchmark: http://attractivechaos.wordpress.com/2011/04/25/my-programming-language-benchmarks-plb/ http://attractivechaos.github.com/plb/ (The matrix mul code is not a realistic exampl

Re: Programming language benchmarks

2011-04-28 Thread Moritz Warning
On Thu, 28 Apr 2011 07:50:19 -0400, bearophile wrote: > Moritz Warning: > >> I think this might be interesting; it's also using D. > > I was about to post this :-) I was surprised you haven't had already. Looks like I got lucky. :-) Have you seen somewhere what compiler options he did use for g

Re: How about a Hash template?

2011-04-28 Thread Andrej Mitrovic
You seem to be right. It looks like DMD is pretty good at optimizing if statements. The Hash version is quite a bit slower actually. Well, that's what happens when I assume things. :) Here's a little benchmark of searching an array and hash of randomly generated strings: http://pastebin.com/GddUn

Re: deprecated delete and manual memory management

2011-04-28 Thread Steven Schveighoffer
On Wed, 27 Apr 2011 18:15:26 -0400, Alexander wrote: On 27.04.2011 22:42, Steven Schveighoffer wrote: For non-garbage-collected languages, yes. For GC languages, delete is to be discouraged (that is what the GC is for). delete() is 99% of the cases O(1) operation (thanks to free lists),

Re: How about a Hash template?

2011-04-28 Thread Alexander
On 28.04.2011 16:25, Andrej Mitrovic wrote: > Here's a little benchmark of searching an array and hash of randomly > generated strings: Make it 16 values and run again :) Sure, the more elements we have, the better hash performs. But in case of ints/floats, for instance, for small sets espe

Re: Deterministic resource freeing - delete deprecation (again)

2011-04-28 Thread Steven Schveighoffer
On Wed, 27 Apr 2011 17:30:54 -0400, Alexander wrote: On 27.04.2011 19:13, Steven Schveighoffer wrote: clear is not a keyword, it is possible to name a member clear, and also have a clear global function. Sure it is, though it is counter-intuitive - to use same name with quite different

Re: deprecated delete and manual memory management

2011-04-28 Thread Alexander
On 28.04.2011 16:52, Steven Schveighoffer wrote: >> delete() is 99% of the cases O(1) operation (thanks to free lists), > > Not exactly, it still needs to update the metadata for the block, which > involves a binary search (O(lgn)) + you have to take the global lock, which > means you could b

Re: How about a Hash template?

2011-04-28 Thread Andrej Mitrovic
"InSet!(var, values...)." That wouldn't work because var is known only at runtime. Ideally I'd like to write something like: string needle = "foo"; if (needle.InSet!("bar", "barfoo", "doo", "foo")) { } And InSet would mixin and call a function such as: bool inSet(string needle) { if (needle

Re: How about a Hash template?

2011-04-28 Thread Peter Alexander
On 28/04/11 4:24 PM, Andrej Mitrovic wrote: "InSet!(var, values...)." That wouldn't work because var is known only at runtime. Ideally I'd like to write something like: string needle = "foo"; if (needle.InSet!("bar", "barfoo", "doo", "foo")) { } And InSet would mixin and call a function such a

Re: deprecated delete and manual memory management

2011-04-28 Thread Steven Schveighoffer
On Thu, 28 Apr 2011 11:11:41 -0400, Alexander wrote: On 28.04.2011 16:52, Steven Schveighoffer wrote: delete() is 99% of the cases O(1) operation (thanks to free lists), Not exactly, it still needs to update the metadata for the block, which involves a binary search (O(lgn)) + you have

Re: std.parallelism is accepted into Phobos

2011-04-28 Thread Andrei Alexandrescu
On 4/28/11 3:24 AM, Jacob Carlborg wrote: On 2011-04-27 21:13, Andrei Alexandrescu wrote: On 4/27/11 1:13 AM, Russel Winder wrote: What also matters is that stuff that stays is stuff that gets done. You seem to have a good amount of expertise, but at the same time choose to firmly plant your fi

Re: Programming language benchmarks

2011-04-28 Thread Andrej Mitrovic
On 4/28/11, Alexander wrote: > On 28.04.2011 13:24, Robert Clipsham wrote: > >> I also notice lots of nested for loops in some of the tests, which should >> be using slice operations really. > > This is the whole point of benchmarking, IMHO - to see how good > compiler/optimizer (and VM, if any)

Re: How about a Hash template?

2011-04-28 Thread Andrej Mitrovic
It works, but it makes the if statement ugly again. :)

Re: Programming language benchmarks

2011-04-28 Thread Andrei Alexandrescu
On 4/28/11 6:10 AM, Francisco Almeida wrote: On 28-04-2011 12:57, Moritz Warning wrote: I think this might be interesting; it's also using D. http://attractivechaos.wordpress.com/2011/04/25/my-programming-language- benchmarks-plb/ Oh dear, the regex results for D are dreadful. And the matmul

Re: Programming language benchmarks

2011-04-28 Thread Andrei Alexandrescu
On 4/28/11 6:50 AM, bearophile wrote: Moritz Warning: I think this might be interesting; it's also using D. I was about to post this :-) The little benchmark: http://attractivechaos.wordpress.com/2011/04/25/my-programming-language-benchmarks-plb/ http://attractivechaos.github.com/plb/ (The m

Re: deprecated delete and manual memory management

2011-04-28 Thread Alexander
On 28.04.2011 17:32, Steven Schveighoffer wrote: > This is not how it's implemented. The metadata is kept in a separate page > from the memory itself. Huh? Could you please elaborate, what do you mean by "metadata" and why it has to be kept on a separate page? I've seen at least one GC im

Re: How about a Hash template?

2011-04-28 Thread Alexander
On 28.04.2011 17:46, Andrej Mitrovic wrote: > It works, but it makes the if statement ugly again. :) Well, just a bit - still much better than (var == "..." || var = "..." || var == "..." ...), don't you think so? ;) If compiler would support special "in" usage, automatically expanding valu

Re: Programming language benchmarks

2011-04-28 Thread Alexander
On 28.04.2011 17:44, Andrej Mitrovic wrote: > > But then these are not programming >language< benchmarks, they are >compiler< > benchmarks. "compiler benchmark" is something that should measure compilation speed, for instance, but "language benchmark" shows how good specific language (+ com

Re: How about a Hash template?

2011-04-28 Thread Andrei Alexandrescu
On 4/28/11 11:00 AM, Alexander wrote: On 28.04.2011 17:46, Andrej Mitrovic wrote: It works, but it makes the if statement ugly again. :) Well, just a bit - still much better than (var == "..." || var = "..." || var == "..." ...), don't you think so? ;) If compiler would support specia

Re: Programming language benchmarks

2011-04-28 Thread Daniel Gibson
Am 28.04.2011 18:10, schrieb Alexander: > On 28.04.2011 17:44, Andrej Mitrovic wrote: > >> >> But then these are not programming >language< benchmarks, they are >> >compiler< benchmarks. > > "compiler benchmark" is something that should measure compilation speed, > for instance, but "language

Re: How about a Hash template?

2011-04-28 Thread Andrej Mitrovic
Well, DMD accepts this kind of syntax already: if (value == val1, val2, val3) { } I think this turns the expression value==val1 into a bool, and then turns val2 and val3 into bools and compares against each of them. Or something like that. It's odd and I've never seen it used anywhere. Maybe we

Re: deprecated delete and manual memory management

2011-04-28 Thread Steven Schveighoffer
On Thu, 28 Apr 2011 11:57:00 -0400, Alexander wrote: On 28.04.2011 17:32, Steven Schveighoffer wrote: This is not how it's implemented. The metadata is kept in a separate page from the memory itself. Huh? Could you please elaborate, what do you mean by "metadata" and why it has to be

Re: Programming language benchmarks

2011-04-28 Thread bearophile
Andrei: > Cristi's GSoC project may target linear algebra operations. That benchmark code is not a realistic example because don't write matrix multiplications manually like that. But the benchmark has found a weakness in array management that's important anyway. Bye, bearophile

Re: Programming language benchmarks

2011-04-28 Thread Walter Bright
On 4/28/2011 9:19 AM, Daniel Gibson wrote: But there's no need for a D compiler to optimize loops that just copy parts of an array into another array (and similar stuff), because in D you use slices for that - they're (probably) faster and easier to use. So IMHO it's fair to use slices where poss

Re: How about a Hash template?

2011-04-28 Thread Jonathan M Davis
> Well, DMD accepts this kind of syntax already: > > if (value == val1, val2, val3) { } > > I think this turns the expression value==val1 into a bool, and then > turns val2 and val3 into bools and compares against each of them. Or > something like that. It's odd and I've never seen it used anywhe

Re: How about a Hash template?

2011-04-28 Thread Andrej Mitrovic
I know it's not doing that, it was a hypothetical. What I'm saying is I've never seen the comma used this way in code.

Re: How about a Hash template?

2011-04-28 Thread Jonathan M Davis
> I know it's not doing that, it was a hypothetical. What I'm saying is > I've never seen the comma used this way in code. Well, it would almost certainly be bad practice to do so. The comma operator can be very useful in some cases (such as for loops) but should generally be avoided. Here, it's

Re: Programming language benchmarks

2011-04-28 Thread Jens Mueller
Walter Bright wrote: > On 4/28/2011 9:19 AM, Daniel Gibson wrote: > >But there's no need for a D compiler to optimize loops that just copy > >parts of an array into another array (and similar stuff), because in D > >you use slices for that - they're (probably) faster and easier to use. > >So IMHO i

Re: Programming language benchmarks

2011-04-28 Thread Andrei Alexandrescu
On 4/28/11 12:57 PM, Jens Mueller wrote: Walter Bright wrote: On 4/28/2011 9:19 AM, Daniel Gibson wrote: But there's no need for a D compiler to optimize loops that just copy parts of an array into another array (and similar stuff), because in D you use slices for that - they're (probably) fast

Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread Jens Mueller
Andrei Alexandrescu wrote: > On 4/28/11 12:57 PM, Jens Mueller wrote: > >Walter Bright wrote: > >>On 4/28/2011 9:19 AM, Daniel Gibson wrote: > >>>But there's no need for a D compiler to optimize loops that just copy > >>>parts of an array into another array (and similar stuff), because in D > >>>yo

Re: Programming language benchmarks

2011-04-28 Thread Walter Bright
On 4/28/2011 11:29 AM, Andrei Alexandrescu wrote: It's simple - Fortran can assume that all data is unaliased (although aliasing is still technically possible). C, with its intensive pointer-based ethos that makes many aliasing-related optimizations difficult, has annoyed many a Fortran aficionad

Re: Programming language benchmarks

2011-04-28 Thread Jens Mueller
Walter Bright wrote: > On 4/28/2011 11:29 AM, Andrei Alexandrescu wrote: > >It's simple - Fortran can assume that all data is unaliased (although > >aliasing > >is still technically possible). C, with its intensive pointer-based ethos > >that > >makes many aliasing-related optimizations difficult

Re: deprecated delete and manual memory management

2011-04-28 Thread Timon Gehr
Steven Schveighoffer wrote: > Yes, the allocation and free performance could be improved, but it doesn't > change the fact that delete manually is not a huge performance gain, if at > all. My benchmark shows that in the current implementation manual deletion of GC memory is at least 15 times fast

Re: deprecated delete and manual memory management

2011-04-28 Thread Andrei Alexandrescu
On 4/28/11 2:27 PM, Timon Gehr wrote: Steven Schveighoffer wrote: Yes, the allocation and free performance could be improved, but it doesn't change the fact that delete manually is not a huge performance gain, if at all. My benchmark shows that in the current implementation manual deletion of

Re: deprecated delete and manual memory management

2011-04-28 Thread Steven Schveighoffer
On Thu, 28 Apr 2011 15:27:16 -0400, Timon Gehr wrote: Steven Schveighoffer wrote: Yes, the allocation and free performance could be improved, but it doesn't change the fact that delete manually is not a huge performance gain, if at all. My benchmark shows that in the current implementati

Re: How about a Hash template?

2011-04-28 Thread Timon Gehr
Andrei Alexandrescu wrote: > On 4/28/11 11:00 AM, Alexander wrote: >> On 28.04.2011 17:46, Andrej Mitrovic wrote: >> >>> It works, but it makes the if statement ugly again. :) >> >>Well, just a bit - still much better than (var == "..." || var = "..." >|| var == "..." ...), don't you think so?

Re: Programming language benchmarks

2011-04-28 Thread Dmitry Olshansky
On 28.04.2011 15:10, Francisco Almeida wrote: On 28-04-2011 12:57, Moritz Warning wrote: I think this might be interesting; it's also using D. http://attractivechaos.wordpress.com/2011/04/25/my-programming-language- benchmarks-plb/ Oh dear, the regex results for D are dreadful. And the matmul

Re: deprecated delete and manual memory management

2011-04-28 Thread Timon Gehr
Steven Schveighoffer wrote: > I would need to see what your benchmark is before I'd say it was > conclusive. Ok. Version with delete is GC_hints (delete does not give many semantic guarantees, ergo it is a hint), version without delete is GC. It is also attached for convenience. This benchmark t

Re: Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread Walter Bright
On 4/28/2011 11:44 AM, Jens Mueller wrote: Thanks. So if a compiler can assume that pointers do not alias it can generate much better code. What's D's standpoint on that matter then? C99 has restrict. I never came across something similar in D. Const and immutable.

Re: Programming language benchmarks

2011-04-28 Thread Don
bearophile wrote: Andrei: Cristi's GSoC project may target linear algebra operations. That benchmark code is not a realistic example because don't write matrix multiplications manually like that. But the benchmark has found a weakness in array management that's important anyway. Bye, bearo

Re: Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread Jens Mueller
Walter Bright wrote: > On 4/28/2011 11:44 AM, Jens Mueller wrote: > >Thanks. So if a compiler can assume that pointers do not alias it can > >generate much better code. What's D's standpoint on that matter then? > >C99 has restrict. I never came across something similar in D. > > Const and immutab

Re: OOP, faster data layouts, compilers

2011-04-28 Thread Don
Peter Alexander wrote: On 26/04/11 9:01 AM, Don wrote: Sean Cavanaugh wrote: In many ways the biggest thing I use regularly in game development that I would lose by moving to D would be good built-in SIMD support. Yes. It is for primarily for this reason that we made static arrays return-by-

Re: Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread Timon Gehr
> That allows specifying that the memory pointed to is only readable which > enables doing the optimizations. But what if the memory is writable but > I can my sure that the pointers pointing to it will never alias? How do > I pass that information to the compiler? > > Jens assert(p1 != p2); (or a

Re: Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread Jens Mueller
Timon Gehr wrote: > > That allows specifying that the memory pointed to is only readable which > > enables doing the optimizations. But what if the memory is writable but > > I can my sure that the pointers pointing to it will never alias? How do > > I pass that information to the compiler? > > > >

Re: Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread bearophile
Walter: > On 4/28/2011 11:44 AM, Jens Mueller wrote: > > Thanks. So if a compiler can assume that pointers do not alias it can > > generate much better code. What's D's standpoint on that matter then? > > C99 has restrict. I never came across something similar in D. > > Const and immutable. I do

Optimizing with dmd disables floating point exceptions

2011-04-28 Thread Jens Mueller
Hi, checking whether a floating point exception occurred is good coding practice for me. I discovered a strange behavior using dmd. divByZero.d: import std.math; unittest { auto a = 1.0L; assert(!ieeeFlags.divByZero); a /= 0.0L; assert(ieeeFlags.divByZero); } $ rdmd --main -unitt

Is D cool or what?

2011-04-28 Thread Andrej Mitrovic
Here's a little 100-line thingy that generates a wavetable of some shape (sine, saw, square - although only sine is implemented at the moment), of any length, and of either float or double element type. It stores this inside a struct which can also keep a number of different phases, which do bounds

Re: Is D cool or what?

2011-04-28 Thread Andrej Mitrovic
Oh that last snippet is wrong, it should be: sample = audioTable.table[audioTable.phase[0] += leftPhase]; sample = audioTable.table[audioTable.phase[1] += rightPhase]; :)

Re: Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread bearophile
> "restrict" means "this pointer has no alias". Jens Mueller is right, it's not just pointers, a.ptr and b.ptr are distinct but they refer to memory zones that are not distinct: auto a = [1, 2, 3, 4, 5]; auto b = [1 .. 3]; Bye, bearophile

Re: Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread bearophile
Jens Mueller: > That allows specifying that the memory pointed to is only readable which > enables doing the optimizations. But what if the memory is writable but > I can my sure that the pointers pointing to it will never alias? How do > I pass that information to the compiler? Here's my answer.

Re: Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread Moritz Warning
On Thu, 28 Apr 2011 17:44:35 -0400, bearophile wrote: > Walter: > >> On 4/28/2011 11:44 AM, Jens Mueller wrote: >> > Thanks. So if a compiler can assume that pointers do not alias it can >> > generate much better code. What's D's standpoint on that matter then? >> > C99 has restrict. I never came

Re: Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread bearophile
Moritz Warning: > When the contents are both const, then there won't be any writing > to it, of course. In that case the same optimizations can be applied as > when they point to different memory. > > both arrays point to different memory. I see, thank you. Bye, bearophile

Re: deprecated delete and manual memory management

2011-04-28 Thread Alexander
On 28.04.2011 18:17, Steven Schveighoffer wrote: > It would seem making the metadata be a constant offset from the data page > would be better, but of course, it cannot be that way for multi-page blocks. Why it cannot? > If you have ideas on how to improve the performance, I encourage you to

Re: How about a Hash template?

2011-04-28 Thread Alexander
On 28.04.2011 21:46, Timon Gehr wrote: > Why is 'in' not currently defined on arrays? To me it seems like a left-out > that > should be fixed, because it has quite obvious and useful semantics. +1. It would be very useful and convenient this way, especially if search will be optimized to seri

Re: Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread Andrei Alexandrescu
On 4/28/11 4:14 PM, Jens Mueller wrote: Walter Bright wrote: On 4/28/2011 11:44 AM, Jens Mueller wrote: Thanks. So if a compiler can assume that pointers do not alias it can generate much better code. What's D's standpoint on that matter then? C99 has restrict. I never came across something sim

Re: Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread bearophile
Andrei: > C's restricts sets a poor example. There are infinite things that a compiler can't prove about the code. Example: the type system can't prove that @system code that uses pointer arithmetic contains no bugs, pointers that go past arrays, etc. C99 restrict is just another example where

Re: How about a Hash template?

2011-04-28 Thread Torarin
2011/4/29 Alexander : > On 28.04.2011 21:46, Timon Gehr wrote: > >> Why is 'in' not currently defined on arrays? To me it seems like a left-out >> that >> should be fixed, because it has quite obvious and useful semantics. > >  +1. It would be very useful and convenient this way, especially if sea

Re: Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread Andrei Alexandrescu
On 4/28/11 7:53 PM, bearophile wrote: Andrei: C's restricts sets a poor example. There are infinite things that a compiler can't prove about the code. Restrict is particularly bad. See http://www.lysator.liu.se/c/dmr-on-noalias.html (noalias was the initial name of restrict). Andrei

Re: Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread Don
Jens Mueller wrote: Andrei Alexandrescu wrote: On 4/28/11 12:57 PM, Jens Mueller wrote: Walter Bright wrote: On 4/28/2011 9:19 AM, Daniel Gibson wrote: But there's no need for a D compiler to optimize loops that just copy parts of an array into another array (and similar stuff), because in D

Re: Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread Walter Bright
On 4/28/2011 9:10 PM, Don wrote: D reduces the use of pointers. You can do much more with arrays. True, but dynamic arrays offer no inherent protection against overlap, though you can add a runtime check for that.

Re: Pointer aliasing in D (Was: Programming language benchmarks)

2011-04-28 Thread Francisco Almeida
== Quote from Walter Bright (newshou...@digitalmars.com)'s article > True, but dynamic arrays offer no inherent protection against overlap, though > you can add a runtime check for that. Another reason why we should have memory pool support in Phobos.

Re: Optimizing with dmd disables floating point exceptions

2011-04-28 Thread Walter Bright
On 4/28/2011 3:02 PM, Jens Mueller wrote: Hi, checking whether a floating point exception occurred is good coding practice for me. I discovered a strange behavior using dmd. divByZero.d: import std.math; unittest { auto a = 1.0L; assert(!ieeeFlags.divByZero); a /= 0.0L; asse

Re: Optimizing with dmd disables floating point exceptions

2011-04-28 Thread KennyTM~
On Apr 29, 11 14:27, Walter Bright wrote: That's because the a/=1.0L; is a dead assignment and is removed by the optimizer. I'd say it's a wrong-code bug. - import std.math, std.stdio; void main() { auto a = 1.0, b = 0.0; writeln(a); writeln(i