The Demise of Dynamic Arrays?!

2009-12-14 Thread S
Excuse me, because I haven't been active in the D community the last year due to school concerns. However, I have been fiddling with the language and on this newsgroups since 2001. As I understand it, dynamic arrays are going away soon in D2.0 in favor of an ArrayBuilder class. I don't li

Re: Detecting inadvertent use of integer division

2009-12-14 Thread Peter
Don Wrote: > BTW, does Python allow integer division of floating point numbers? > eg, int_a = float_b // float_c; ? > (meaning cast(int)float_b / (cast(int)float_c); ). Python doesn't have integer division, but floor division, and it's perefctly valid if arguments are floats, as name says it's

Re: Detecting inadvertent use of integer division

2009-12-14 Thread Bob Jones
"bearophile" wrote in message news:hg6rns$ta...@digitalmars.com... > > > Even if you find a fitting operator, how can you restrict \ to just > floating point division > and keep some compatibility with C code? Isnt compatibility with C already broken anyway? But yeah if C compatibility is a c

Re: Short list with things to finish for D2

2009-12-14 Thread lws
On 2009-11-20 02:18:03 -0800, Pelle Månsson said: Andrei Alexandrescu wrote: Bill Baxter wrote: On Thu, Nov 19, 2009 at 8:46 AM, Andrei Alexandrescu wrote: grauzone wrote: What's with opSomethingAssign (or "expr1[expr2] @= expr3" in general)? opBinary doesn't seem to solve any of those. o

Re: Short list with things to finish for D2

2009-12-14 Thread lws
On 2009-11-19 15:46:57 -0800, Bill Baxter said: On Wed, Nov 18, 2009 at 8:33 PM, Andrei Alexandrescu wrote: I am thinking that representing operators by their exact token representation is a principled approach because it allows for unambiguous mapping, There used to be an argument floatin

Re: opEquals(const ref yadaYada)

2009-12-14 Thread lws
On 2009-12-14 11:04:53 -0800, Leandro Lucarella said: lws, el 14 de diciembre a las 08:31 me escribiste: Unless I'm confused, classses are ALWAYS heap (unless explicitely scoped) objects in D. Yes, and classes are always references too. But that's not even the point, the point is, the exampl

Re: Detecting inadvertent use of integer division

2009-12-14 Thread Phil Deets
On Mon, 14 Dec 2009 04:57:26 -0500, Don wrote: In the very rare cases where the result of an integer division was actually intended to be stored in a float, an explicit cast would be required. So you'd write: double y = cast(int)(1/x); To me, double y = cast(double)(1/x); makes more sen

Re: D2 GUI Libs

2009-12-14 Thread Nick Sabalausky
"Michel Fortin" wrote in message news:hg6she$ub...@digitalmars.com... > On 2009-12-14 20:56:12 -0500, "Nick Sabalausky" said: > >> "Andrei Alexandrescu" wrote in message >> news:hg698i$2rp...@digitalmars.com... >>> Maybe opDispatch could help the use scenario. >>> >>> Andrei >> >> As opDispatch

Re: Detecting inadvertent use of integer division

2009-12-14 Thread Jason House
Don Wrote: > Walter Bright wrote: > > Don wrote: > >> Consider this notorious piece of code: > >> > >> assert(x>1); > >> double y = 1 / x; > >> > >> This calculates y as the reciprocal of x, if x is a floating-point > >> number. But if x is an integer, an integer division is performed > >> inste

Re: D2 GUI Libs

2009-12-14 Thread Michel Fortin
On 2009-12-14 20:56:12 -0500, "Nick Sabalausky" said: "Andrei Alexandrescu" wrote in message news:hg698i$2rp...@digitalmars.com... Maybe opDispatch could help the use scenario. Andrei As opDispatch pushes errors from compile-time to run-time, I don't think we should be encouraging its use

Re: Go rant

2009-12-14 Thread Mike Farnsworth
bearophile Wrote: > Sean Kelly: > > If I had to guess I'd say that he's referring to that fact that value types > > in Java are second-class citizens. The standard containers can only hold > > objects, so boxing is necessary,< > > Reading that page I have thought he wants all data to be manage

Re: D2 GUI Libs

2009-12-14 Thread Andrei Alexandrescu
Nick Sabalausky wrote: "Andrei Alexandrescu" wrote in message news:hg698i$2rp...@digitalmars.com... Michel Fortin wrote: On 2009-12-14 11:41:58 -0500, Andrei Alexandrescu said: Adam D. Ruppe wrote: On Mon, Dec 14, 2009 at 07:24:11AM -0800, Andrei Alexandrescu wrote: D2 will include proper

Re: Windows multi-threading performance issues on multi-core systems only

2009-12-14 Thread dsimcha
== Quote from Dan (dsstruth...@yahoo.com)'s article > I have a question regarding performance issue I am seeing on multicore Windows systems. I am creating many threads to do parallel tasks, and on multicore Windows systems the performance is abysmal. If I use task manager to set the processor af

Re: Detecting inadvertent use of integer division

2009-12-14 Thread bearophile
Bob Jones: > The fact that adding a specific intdiv operator would not only avoid more > casting, but remove the the need for casting in a lot of existing cases > should count pretty well against the "no more operator/keywords" argument. In D you can't use // used in Python, because it's used to

Re: Detecting inadvertent use of integer division

2009-12-14 Thread Bob Jones
"Don" wrote in message news:hg5nkk$1n3...@digitalmars.com... > bearophile wrote: >> Don: In Pascal too (and OCaML, but the situation is different) they are separated. I think here having two operators is better, >>> Why? >> >> You are intelligent and expert so you must know my answer,

Re: D2 GUI Libs

2009-12-14 Thread Nick Sabalausky
"Andrei Alexandrescu" wrote in message news:hg698i$2rp...@digitalmars.com... > Michel Fortin wrote: >> On 2009-12-14 11:41:58 -0500, Andrei Alexandrescu >> said: >> >>> Adam D. Ruppe wrote: On Mon, Dec 14, 2009 at 07:24:11AM -0800, Andrei Alexandrescu wrote: > D2 will include propertie

Re: Go rant

2009-12-14 Thread bearophile
There are things that I read often around in blogs and papers (and sometimes even in books), but sometimes I keep not understanding them. Sean Kelly: > If I had to guess I'd say that he's referring to that fact that value types > in Java are second-class citizens. The standard containers can on

Windows multi-threading performance issues on multi-core systems only

2009-12-14 Thread Dan
I have a question regarding performance issue I am seeing on multicore Windows systems. I am creating many threads to do parallel tasks, and on multicore Windows systems the performance is abysmal. If I use task manager to set the processor affinity to a single CPU, the program runs as I would

Re: Go rant

2009-12-14 Thread Sean Kelly
bearophile Wrote: > This is a mostly boring rant against the Go language: > http://monoc.mo.funpic.de/go-rant/ > > Near the end it contains an interesting bit: > >Too, why this divide, again, with reference types and value types? Did they > >not learn from the problems this caused in Java? While

Go rant

2009-12-14 Thread bearophile
This is a mostly boring rant against the Go language: http://monoc.mo.funpic.de/go-rant/ Near the end it contains an interesting bit: >Too, why this divide, again, with reference types and value types? Did they >not learn from the problems this caused in Java? While Java slowly struggles >its wa

Re: const ref rvalues

2009-12-14 Thread Andrei Alexandrescu
Denis Koroskin wrote: On Mon, 14 Dec 2009 23:38:34 +0300, Andrei Alexandrescu wrote: Denis Koroskin wrote: On Mon, 14 Dec 2009 21:06:20 +0300, dsimcha wrote: I mentioned this deep in another thread, but I think it deserves its own thread. Can we get something like: void doStuff(T)(cons

Re: const ref rvalues

2009-12-14 Thread Andrei Alexandrescu
Denis Koroskin wrote: On Mon, 14 Dec 2009 22:15:06 +0300, Andrei Alexandrescu wrote: Eldar Insafutdinov wrote: dsimcha Wrote: I mentioned this deep in another thread, but I think it deserves its own thread. Can we get something like: void doStuff(T)(const ref T val) { // do stuff. }

Re: D2 GUI Libs

2009-12-14 Thread Michel Fortin
On 2009-12-14 16:04:18 -0500, Andrei Alexandrescu said: Michel Fortin wrote: On 2009-12-14 11:41:58 -0500, Andrei Alexandrescu said: Adam D. Ruppe wrote: On Mon, Dec 14, 2009 at 07:24:11AM -0800, Andrei Alexandrescu wrote: D2 will include properties that are understood by the compiler. W

Re: const ref rvalues

2009-12-14 Thread Denis Koroskin
On Mon, 14 Dec 2009 23:38:34 +0300, Andrei Alexandrescu wrote: Denis Koroskin wrote: On Mon, 14 Dec 2009 21:06:20 +0300, dsimcha wrote: I mentioned this deep in another thread, but I think it deserves its own thread. Can we get something like: void doStuff(T)(const ref T val) { //

Re: const ref rvalues

2009-12-14 Thread Denis Koroskin
On Mon, 14 Dec 2009 22:15:06 +0300, Andrei Alexandrescu wrote: Eldar Insafutdinov wrote: dsimcha Wrote: I mentioned this deep in another thread, but I think it deserves its own thread. Can we get something like: void doStuff(T)(const ref T val) { // do stuff. } T getVal() { re

Re: const ref rvalues

2009-12-14 Thread dsimcha
== Quote from Jason House (jason.james.ho...@gmail.com)'s article > If T is a class, I agree it should work. If T is a struct, you'll need a stronger argument. Maybe scope const ref T would make sense. IMHO, non- scope ref T for structs is already a questionable practice, and I don't mind the comp

Re: D2 GUI Libs

2009-12-14 Thread Andrei Alexandrescu
Michel Fortin wrote: On 2009-12-14 11:41:58 -0500, Andrei Alexandrescu said: Adam D. Ruppe wrote: On Mon, Dec 14, 2009 at 07:24:11AM -0800, Andrei Alexandrescu wrote: D2 will include properties that are understood by the compiler. We currently don't have a design for user-defined properties

Re: D2 GUI Libs

2009-12-14 Thread Michel Fortin
On 2009-12-14 11:41:58 -0500, Andrei Alexandrescu said: Adam D. Ruppe wrote: On Mon, Dec 14, 2009 at 07:24:11AM -0800, Andrei Alexandrescu wrote: D2 will include properties that are understood by the compiler. We currently don't have a design for user-defined properties. Can I suggest some

Re: Detecting inadvertent use of integer division

2009-12-14 Thread bearophile
Don: >You've used Python extensively, I haven't.< The situation with Python isn't the same of D because Python has dynamic typing, so your operations must always know what they return (and their return type can change when necessary). >in what contexts is / ambiguous or difficult to read?< A

Re: const ref rvalues

2009-12-14 Thread Andrei Alexandrescu
Denis Koroskin wrote: On Mon, 14 Dec 2009 21:06:20 +0300, dsimcha wrote: I mentioned this deep in another thread, but I think it deserves its own thread. Can we get something like: void doStuff(T)(const ref T val) { // do stuff. } T getVal() { return someValue; } void main() {

Re: const ref rvalues

2009-12-14 Thread Denis Koroskin
On Mon, 14 Dec 2009 21:06:20 +0300, dsimcha wrote: I mentioned this deep in another thread, but I think it deserves its own thread. Can we get something like: void doStuff(T)(const ref T val) { // do stuff. } T getVal() { return someValue; } void main() { doStuff(getVal()); //

Re: const ref rvalues

2009-12-14 Thread Jason House
dsimcha Wrote: > I mentioned this deep in another thread, but I think it deserves its own > thread. Can we get something like: > > void doStuff(T)(const ref T val) { > // do stuff. > } > > T getVal() { > return someValue; > } > > void main() { > doStuff(getVal()); // Doesn't curre

Re: D2 GUI Libs

2009-12-14 Thread Jacob Carlborg
On 12/14/09 20:29, Jacob Carlborg wrote: On 12/13/09 20:44, Eldar Insafutdinov wrote: Nick Sabalausky Wrote: "Nick Sabalausky" wrote in message news:hg394f$mr...@digitalmars.com... "Eldar Insafutdinov" wrote in message news:hg2p87$2tt...@digitalmars.com... 1) You may know the concept of sig

Re: Detecting inadvertent use of integer division

2009-12-14 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Sean Kelly wrote: > Don Wrote: > >> Walter Bright wrote: >>> Don wrote: (This means that double y = int_val / 1; is OK, and also: double z = 90/3; would be OK. An alternative rule would be: "If an integer expression involves integer d

Re: D2 GUI Libs

2009-12-14 Thread Jacob Carlborg
On 12/13/09 20:44, Eldar Insafutdinov wrote: Nick Sabalausky Wrote: "Nick Sabalausky" wrote in message news:hg394f$mr...@digitalmars.com... "Eldar Insafutdinov" wrote in message news:hg2p87$2tt...@digitalmars.com... 1) You may know the concept of signals and slots in Qt. Consider the follo

Re: const ref rvalues

2009-12-14 Thread Andrei Alexandrescu
Eldar Insafutdinov wrote: dsimcha Wrote: I mentioned this deep in another thread, but I think it deserves its own thread. Can we get something like: void doStuff(T)(const ref T val) { // do stuff. } T getVal() { return someValue; } void main() { doStuff(getVal()); // Doesn't cu

Re: opEquals(const ref yadaYada)

2009-12-14 Thread Leandro Lucarella
lws, el 14 de diciembre a las 08:31 me escribiste: > Unless I'm confused, classses are ALWAYS heap (unless explicitely > scoped) objects in D. Yes, and classes are always references too. But that's not even the point, the point is, the example was a struct :) > >>>struct Foo { > >>>bool opEquals(

Re: const ref rvalues

2009-12-14 Thread Eldar Insafutdinov
dsimcha Wrote: > I mentioned this deep in another thread, but I think it deserves its own > thread. Can we get something like: > > void doStuff(T)(const ref T val) { > // do stuff. > } > > T getVal() { > return someValue; > } > > void main() { > doStuff(getVal()); // Doesn't curre

Re: Sorting not happpening ... ???

2009-12-14 Thread bearophile
Ignore this, it's caused by the online interface, sorry.

Re: Detecting inadvertent use of integer division

2009-12-14 Thread Walter Bright
Don wrote: Integer expressions remain inexact until there's a cast. (It's very simple to implement, you just use the integer range code, adding an 'inexact' flag. Division sets the flag, casts clear the flag, everything else just propagates it if a unary operation, or ORs the two flags if a b

const ref rvalues

2009-12-14 Thread dsimcha
I mentioned this deep in another thread, but I think it deserves its own thread. Can we get something like: void doStuff(T)(const ref T val) { // do stuff. } T getVal() { return someValue; } void main() { doStuff(getVal()); // Doesn't currently work. } For non-const ref parameters

Re: Sorting not happpening ... ???

2009-12-14 Thread bearophile
Matthew: A cleaned up case: struct B { A a; } static if(true) struct A {} void main() {} I think this may be a forward reference bug... Bye, bearophile

Re: opEquals(const ref yadaYada)

2009-12-14 Thread dsimcha
== Quote from lws (inva...@email.com)'s article > On 2009-12-14 07:01:47 -0800, dsimcha said: > > == Quote from lws (inva...@email.com)'s article > >> I don't know if I believe this is necesarrily bad. It's revealing some > >> bad coding on your part. > >> You shouldn't be doing opEquals with an

Re: Reference Counting Template

2009-12-14 Thread Lutger
Denis Koroskin wrote: > On Mon, 14 Dec 2009 11:04:15 +0300, Lutger > wrote: > >> What are you planning to with multithreading? >> >> With the current type system, is it possible to statically detect inside >> the >> template if the refcount is used in shared scenario's, and base the >> implement

Re: D2 GUI Libs

2009-12-14 Thread Nick Sabalausky
"bobef" wrote in message news:hg5qr6$1t9...@digitalmars.com... > Andrei Alexandrescu Wrote: > >> > I would say that QtD is in the state close to that of D2, almost >> > there, but not quite ready yet. But we intend to release the next >> > version, which will be ready to use earlier than D2 anywa

Re: D2 GUI Libs

2009-12-14 Thread Nick Sabalausky
"Kagamin" wrote in message news:hg5bnt$110...@digitalmars.com... > Nick Sabalausky Wrote: > >>- Many GTK apps use the absolute *worst* and most impractical file >> dialog >> boxes I've seen in over 15 years. This is never an issue with native >> apps. > > I like how gimp dialog box provides

Re: D2 GUI Libs

2009-12-14 Thread bobef
Andrei Alexandrescu Wrote: > > I would say that QtD is in the state close to that of D2, almost > > there, but not quite ready yet. But we intend to release the next > > version, which will be ready to use earlier than D2 anyway, I would > > say within a month. > > I salute the decision of going

Re: Detecting inadvertent use of integer division

2009-12-14 Thread lws
On 2009-12-14 03:16:27 -0800, Don said: Walter Bright wrote: Don wrote: Consider this notorious piece of code: assert(x>1); double y = 1 / x; This calculates y as the reciprocal of x, if x is a floating-point number. But if x is an integer, an integer division is performed instead of a fl

Re: D2 GUI Libs

2009-12-14 Thread Andrei Alexandrescu
Adam D. Ruppe wrote: On Mon, Dec 14, 2009 at 07:24:11AM -0800, Andrei Alexandrescu wrote: D2 will include properties that are understood by the compiler. We currently don't have a design for user-defined properties. Can I suggest something very simple: make them accessible from __traits, and l

Re: opEquals(const ref yadaYada)

2009-12-14 Thread lws
On 2009-12-14 07:01:47 -0800, dsimcha said: == Quote from lws (inva...@email.com)'s article I don't know if I believe this is necesarrily bad. It's revealing some bad coding on your part. You shouldn't be doing opEquals with an rvalue of a class. Make getFoo return a reference. ref Foo getF

Re: opEquals(const ref yadaYada)

2009-12-14 Thread lws
Unless I'm confused, classses are ALWAYS heap (unless explicitely scoped) objects in D. The garbage collector is the one that is tasked with reclaiming their memory and calling their deconstructor. If you want the semantics you're talking about Foo would need to be a "scoped Foo foo = new Fo

Re: D2 GUI Libs

2009-12-14 Thread Adam D. Ruppe
On Mon, Dec 14, 2009 at 07:42:51AM -0800, Andrei Alexandrescu wrote: > Probably it's easier to (also) offer is(a == @myprop). Yeah, that works too. As long as we have some kind of building block. > But we couldn't make static foreach part of D2. Oh well, no big deal; we can make do without it.

Re: Detecting inadvertent use of integer division

2009-12-14 Thread Don
bearophile wrote: Don: In Pascal too (and OCaML, but the situation is different) they are separated. I think here having two operators is better, Why? You are intelligent and expert so you must know my answer, so I fear yours is a trick question :-) No, it's not a trick question. You've us

Re: Reference Counting Template

2009-12-14 Thread LMB
dsimcha Wrote: > I'm starting to think it would be both useful and feasible to have a general > reference counting template struct in Phobos: > [...] > Does this sound > worthwhile? Yes it does :-) I believe this would be great for working with many C-based APIs. I recently needed this when cre

Re: Detecting inadvertent use of integer division

2009-12-14 Thread Saaa
Don wrote > Consider this notorious piece of code: > > assert(x>1); > double y = 1 / x; > > This calculates y as the reciprocal of x, if x is a floating-point number. > But if x is an integer, an integer division is performed instead of a > floating-point one, and y will be 0. > > It's a very com

Re: Detecting inadvertent use of integer division

2009-12-14 Thread Sean Kelly
Don Wrote: > Walter Bright wrote: > > Don wrote: > >> > >> (This means that double y = int_val / 1; is OK, and also: > >> double z = 90/3; would be OK. An alternative rule would be: > >> "If an integer expression involves integer divison, that expression > >> cannot be implicitly cast to a floa

Re: D2 GUI Libs

2009-12-14 Thread Andrei Alexandrescu
Adam D. Ruppe wrote: On Mon, Dec 14, 2009 at 07:24:11AM -0800, Andrei Alexandrescu wrote: D2 will include properties that are understood by the compiler. We currently don't have a design for user-defined properties. Can I suggest something very simple: make them accessible from __traits, and l

Re: D2 GUI Libs

2009-12-14 Thread Adam D. Ruppe
On Mon, Dec 14, 2009 at 07:24:11AM -0800, Andrei Alexandrescu wrote: > D2 will include properties that are understood by the compiler. We > currently don't have a design for user-defined properties. Can I suggest something very simple: make them accessible from __traits, and leave the rest to the

Re: D2 GUI Libs

2009-12-14 Thread Andrei Alexandrescu
Eldar Insafutdinov wrote: Andrei Alexandrescu Wrote: Eldar Insafutdinov wrote: Andrei Alexandrescu Wrote: Thanks for cooperation. I don't want to sound like I've given the right to ask for features, because I am working on a particular D project. But at the same time, indeed, while working on

Re: Detecting inadvertent use of integer division

2009-12-14 Thread Aelxx
"bearophile" wrote: > Don: >> > In Pascal too (and OCaML, but the situation is different) they are >> > separated. I think here having two operators is better, >> >> Why? > > You are intelligent and expert so you must know my answer, so I fear yours > is a trick question :-) > > Two operators a

Re: opEquals(const ref yadaYada)

2009-12-14 Thread dsimcha
== Quote from lws (inva...@email.com)'s article > I don't know if I believe this is necesarrily bad. It's revealing some > bad coding on your part. > You shouldn't be doing opEquals with an rvalue of a class. Make > getFoo return a reference. > ref Foo getFoo() {} fixes the problem and avoids va

Re: Reference Counting Template

2009-12-14 Thread dsimcha
== Quote from Lutger (lutger.blijdest...@gmail.com)'s article > What are you planning to with multithreading? > With the current type system, is it possible to statically detect inside the > template if the refcount is used in shared scenario's, and base the > implementation on that information? Th

Re: opEquals(const ref yadaYada)

2009-12-14 Thread Leandro Lucarella
lws, el 14 de diciembre a las 01:06 me escribiste: > I don't know if I believe this is necesarrily bad. It's revealing > some bad coding on your part. > > You shouldn't be doing opEquals with an rvalue of a class. Make > getFoo return a reference. > > ref Foo getFoo() {} fixes the problem and

Re: Detecting inadvertent use of integer division

2009-12-14 Thread bearophile
Don: > > In Pascal too (and OCaML, but the situation is different) they are > > separated. I think here having two operators is better, > > Why? You are intelligent and expert so you must know my answer, so I fear yours is a trick question :-) Two operators allow to reduce the need for casts

Re: Detecting inadvertent use of integer division

2009-12-14 Thread Don
bearophile wrote: Don: In the opPow thread there were a couple of mentions of inadvertent integer division, and how Python is removing this error by making / always mean floating-point division, and introducing a new operator for integer division. In Pascal too (and OCaML, but the situation

Re: D2 GUI Libs

2009-12-14 Thread Kagamin
Nick Sabalausky Wrote: >- Many GTK apps use the absolute *worst* and most impractical file dialog > boxes I've seen in over 15 years. This is never an issue with native apps. I like how gimp dialog box provides mruds, which is not done by virtually any other windows application, this is ext

Re: Detecting inadvertent use of integer division

2009-12-14 Thread bearophile
Don: > In the opPow thread there were a couple of mentions of inadvertent > integer division, and how Python is removing this error by making / > always mean floating-point division, and introducing a new operator for > integer division. In Pascal too (and OCaML, but the situation is different)

Re: Detecting inadvertent use of integer division

2009-12-14 Thread Don
Walter Bright wrote: Don wrote: Consider this notorious piece of code: assert(x>1); double y = 1 / x; This calculates y as the reciprocal of x, if x is a floating-point number. But if x is an integer, an integer division is performed instead of a floating-point one, and y will be 0. It's a

Re: D2 GUI Libs

2009-12-14 Thread Bill Baxter
On Mon, Dec 14, 2009 at 2:24 AM, Lars T. Kyllingstad wrote: > dsimcha wrote: >> >> == Quote from retard (r...@tard.com.invalid)'s article >>> >>> Sat, 12 Dec 2009 05:10:24 +, dsimcha wrote: 2.  Native look and feel.  IMHO this is very overrated.  I've never found that a Java-ish

Re: D2 GUI Libs

2009-12-14 Thread Lars T. Kyllingstad
dsimcha wrote: == Quote from retard (r...@tard.com.invalid)'s article Sat, 12 Dec 2009 05:10:24 +, dsimcha wrote: 2. Native look and feel. IMHO this is very overrated. I've never found that a Java-ish or GTK-ish or whatever look and feel instead of a native Win32 look and feel got in the

Re: Detecting inadvertent use of integer division

2009-12-14 Thread Walter Bright
Don wrote: Consider this notorious piece of code: assert(x>1); double y = 1 / x; This calculates y as the reciprocal of x, if x is a floating-point number. But if x is an integer, an integer division is performed instead of a floating-point one, and y will be 0. It's a very common newbie tr

Detecting inadvertent use of integer division

2009-12-14 Thread Don
Consider this notorious piece of code: assert(x>1); double y = 1 / x; This calculates y as the reciprocal of x, if x is a floating-point number. But if x is an integer, an integer division is performed instead of a floating-point one, and y will be 0. It's a very common newbie trap, but I fi

Re: Reference Counting Template

2009-12-14 Thread Denis Koroskin
On Mon, 14 Dec 2009 11:04:15 +0300, Lutger wrote: What are you planning to with multithreading? With the current type system, is it possible to statically detect inside the template if the refcount is used in shared scenario's, and base the implementation on that information? That would b

Re: opEquals(const ref yadaYada)

2009-12-14 Thread lws
On 2009-12-13 04:29:28 -0800, Steven Schveighoffer said: Richard Webb Wrote: Hi, I mentioned this problem in the thread @ http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=18405 I ran into the rvalue problem while trying to get Juno to compile, an

Re: opEquals(const ref yadaYada)

2009-12-14 Thread lws
I don't know if I believe this is necesarrily bad. It's revealing some bad coding on your part. You shouldn't be doing opEquals with an rvalue of a class. Make getFoo return a reference. ref Foo getFoo() {} fixes the problem and avoids value-copying for no reason to an rvalue that's going

Re: Reference Counting Template

2009-12-14 Thread Lutger
What are you planning to with multithreading? With the current type system, is it possible to statically detect inside the template if the refcount is used in shared scenario's, and base the implementation on that information? That would be ideal, if it is indeed possible. std.stdio.File is r

Re: D2 GUI Libs

2009-12-14 Thread Eldar Insafutdinov
Andrei Alexandrescu Wrote: > Eldar Insafutdinov wrote: > > Andrei Alexandrescu Wrote: > > Thanks for cooperation. I don't want to sound like I've given the > > right to ask for features, because I am working on a particular D > > project. But at the same time, indeed, while working on this project