Re: Hacking on Phobos

2012-04-18 Thread Jacob Carlborg
On 2012-04-17 20:47, H. S. Teoh wrote: You can just edit /etc/dmd.conf to that effect (if it conflicts with your stable version of dmd, you could try to change the git dmd source to look for dmd.conf in a different place, say /usr/src/d-devel/dmd.conf or something, and so you can completely

Re: Aquivalent References as in C++?

2012-04-18 Thread Namespace
On Tuesday, 17 April 2012 at 23:56:12 UTC, bearophile wrote: Namespace: Another idea: instead scope, in can get a new functionality. Instead as a synonym for const it could mean not null for objects. Note that currently in D2 in means scope const. Bye, bearophile Yes I know. But the

Re: appending newly initialized struct to array

2012-04-18 Thread Kenji Hara
On Wednesday, 18 April 2012 at 04:55:23 UTC, Ali Çehreli wrote: On 04/17/2012 02:00 PM, simendsjo wrote: Sounds like a bug. C style initializers work in other cases: I try not to use them. I think they have this 'feature' of leaving unspecified members uninitialized: struct S { int i;

Re: arrays and foreach

2012-04-18 Thread Somedude
Le 17/04/2012 16:07, Ali Çehreli a écrit : On 04/17/2012 12:42 AM, Somedude wrote: Sorry for hijacking this thread, but since you're around, I hope you'll see this message. As a D beginner, I'm browsing through your book. I wanted to tell you that there is something essential missing in it:

Re: Hacking on Phobos

2012-04-18 Thread Jacob Carlborg
On 2012-04-17 20:10, Joseph Rushton Wakeling wrote: Hello all, As per earlier discussion I'm trying to hack on Phobos to update the random sampling code. To do this I've just copied random.d into a new file, randomsample.d, which I'm modifying and messing around with; I'm trying to build

Re: arrays and foreach

2012-04-18 Thread Somedude
Le 18/04/2012 10:26, Somedude a écrit : Yes, I think that you have a lot of valuable information, but the organization is lacking. The advanced chapters look good, but the first beginner chapters can be . ... largely improved.

Re: Hacking on Phobos

2012-04-18 Thread Somedude
Le 18/04/2012 12:04, Jacob Carlborg a écrit : I can't find any easy or friendly get started hacking on Phobos page, so can anyone advise how to get set up correctly? I've thought about this several times, we need one badly. I've just created a page in the Wiki with the posts here:

Re: appending newly initialized struct to array

2012-04-18 Thread Somedude
Le 18/04/2012 12:41, maarten van damme a écrit : That's a very odd design. Making it work when instantiating a new struct of that type but not inline. Anyway, test(3,5) works perfect, thank you. It's not odd at all. You append a structure, not an array. {3,5} is for array initialization, it's

Re: Aquivalent References as in C++?

2012-04-18 Thread bearophile
Namespace: But i think, i'm probably the only one in D who really wants something like that. I have discussed this topic three or more times, and opened an enhancement request around 2010-08-02: http://d.puremagic.com/issues/show_bug.cgi?id=4571 Bye, bearophile

File Ex from std_stdio won't compile

2012-04-18 Thread Paul
I copied the code below from this site under the std.stdio library reference section and tried to compile it. I downloaded D2/Phobos. Compiler says fileread.d(4): Error: undefined identifier File If I add import std.stdio to the beginning it get ; expected, function declaration w/o return

learn.newbie forum

2012-04-18 Thread Paul
I think there should be a learn.newbie forum. After I post my little problems of a sample code snippet that won't compile, I read some of the other threads. There are those c/c++ programmers learning the ins/outs of D and then there are the greenies like me. Just a thought.

Clearly Label D1/D2/Tango/Phobos

2012-04-18 Thread Paul
I bought the book and am trying to patiently learn this language. I follow various tutorials here and around the web that frequently won't compile. I suspect it has something to do with D1/D2/Phobos/Tango and not just really poor unvetted tutorials. It would really be helpful if those

Re: learn.newbie forum

2012-04-18 Thread simendsjo
On Wed, 18 Apr 2012 14:19:27 +0200, Paul phshaf...@gmail.com wrote: I think there should be a learn.newbie forum. After I post my little problems of a sample code snippet that won't compile, I read some of the other threads. There are those c/c++ programmers learning the ins/outs of D

Re: File Ex from std_stdio won't compile

2012-04-18 Thread simendsjo
On Wed, 18 Apr 2012 14:09:20 +0200, Paul phshaf...@gmail.com wrote: I copied the code below from this site under the std.stdio library reference section and tried to compile it. I downloaded D2/Phobos. Compiler says fileread.d(4): Error: undefined identifier File If I add import

learning D. Experienced issue very quickly.

2012-04-18 Thread Mark
Yeah I bought the book recently and ran into an issue very quickly into it. But this error I keep getting keeps bugging me. Could really use an explanation on why its not compiling. Here is the code. /* Compute heights in centimeters for a range of heights expressed in feet and inches */

Re: learning D. Experienced issue very quickly.

2012-04-18 Thread Steven Schveighoffer
On Wed, 18 Apr 2012 09:10:46 -0400, Mark sectio...@yahoo.com wrote: Yeah I bought the book recently and ran into an issue very quickly into it. But this error I keep getting keeps bugging me. Could really use an explanation on why its not compiling. Here is the code. /* Compute heights

Re: learning D. Experienced issue very quickly.

2012-04-18 Thread simendsjo
On Wed, 18 Apr 2012 15:10:46 +0200, Mark sectio...@yahoo.com wrote: Yeah I bought the book recently and ran into an issue very quickly into it. But this error I keep getting keeps bugging me. Could really use an explanation on why its not compiling. Here is the code. /* Compute heights

Re: learning D. Experienced issue very quickly.

2012-04-18 Thread simendsjo
On Wed, 18 Apr 2012 15:24:12 +0200, Mark sectio...@yahoo.com wrote: Are you using the D1 compiler..? It works on dmd 2.057,8 and 9 at least. Just write dmd, and look at the top for the compiler version. look at that. it says D1. I downloaded both D1 and D2. Better get rid of D1 then. I

Re: learning D. Experienced issue very quickly.

2012-04-18 Thread Mark
Are you using the D1 compiler..? It works on dmd 2.057,8 and 9 at least. Just write dmd, and look at the top for the compiler version. look at that. it says D1. I downloaded both D1 and D2. Better get rid of D1 then. I feel like such an idiot. THank you for the help.

Re: retro() on a `string` creates a range of `dchar`, causing array() pains

2012-04-18 Thread Ali Çehreli
On Wednesday, 18 April 2012 at 05:45:06 UTC, Jakob Ovrum wrote: On Tuesday, 17 April 2012 at 15:36:39 UTC, Ali Çehreli wrote: The reason is, a sequence of UTF-8 code units are not a valid UTF-8 when reversed (or retro'ed :p). But a dchar array can be reversed. Ali It is absolutely

Re: appending newly initialized struct to array

2012-04-18 Thread Ali Çehreli
On 04/18/2012 12:16 AM, Kenji Hara wrote: On Wednesday, 18 April 2012 at 04:55:23 UTC, Ali Çehreli wrote: assert(s.d == double.nan); // -- fails (may work for you) You should use std.math.isNaN whether a floating point value is NaN. assert(isNaN(s.d)); // -- success That a thousandth

Re: Aquivalent References as in C++?

2012-04-18 Thread Namespace
On Wednesday, 18 April 2012 at 11:36:30 UTC, bearophile wrote: Namespace: But i think, i'm probably the only one in D who really wants something like that. I have discussed this topic three or more times, and opened an enhancement request around 2010-08-02:

Re: learning D. Experienced issue very quickly.

2012-04-18 Thread Mirko Pilger
I feel like such an idiot. don't worry. you're not the first and not the last being confused by this.

Re: arrays and foreach

2012-04-18 Thread Ali Çehreli
On 04/18/2012 03:06 AM, Somedude wrote: Le 18/04/2012 10:26, Somedude a écrit : Yes, I think that you have a lot of valuable information, but the organization is lacking. The advanced chapters look good, but the first beginner chapters can be . ... largely improved. Thank you, this is all

Re: learn.newbie forum

2012-04-18 Thread Somedude
Le 18/04/2012 14:19, Paul a écrit : I think there should be a learn.newbie forum. After I post my little problems of a sample code snippet that won't compile, I read some of the other threads. There are those c/c++ programmers learning the ins/outs of D and then there are the greenies like

Re: Clearly Label D1/D2/Tango/Phobos

2012-04-18 Thread Somedude
Le 18/04/2012 14:34, Paul a écrit : I bought the book and am trying to patiently learn this language. I follow various tutorials here and around the web that frequently won't compile. I suspect it has something to do with D1/D2/Phobos/Tango and not just really poor unvetted tutorials. It

.empty and .length Amend language manual?

2012-04-18 Thread dcoder
I'm using the language reference on dlang.org (which is awesome), anyways, I can't find a description of .empty in the array section. Should it be there? I don't see it in the property section either. Could someone more expert than me, add it in somewhere? Thanks. Also, is there any

Re: .empty and .length Amend language manual?

2012-04-18 Thread Tobias Pankrath
On Wednesday, 18 April 2012 at 14:35:07 UTC, dcoder wrote: I'm using the language reference on dlang.org (which is awesome), anyways, I can't find a description of .empty in the array section. Should it be there? I don't see it in the property section either. Could someone more expert than

Re: D-Cocoa Port

2012-04-18 Thread Rizo Isrof
On Friday, 13 April 2012 at 14:28:05 UTC, Jacob Carlborg wrote: On 2012-04-13 15:34, Rizo Isrof wrote: Hi, I am planning to use D for creating native applications on Mac OS X. For that, of course, D must interact with the Cocoa API. I have no knowledge of how this bindings could be done.

Re: Templates in classes = what is wrong?

2012-04-18 Thread Xan
On Tuesday, 17 April 2012 at 18:39:16 UTC, Xan wrote: On Tuesday, 17 April 2012 at 18:25:21 UTC, Ali Çehreli wrote: On 04/17/2012 11:13 AM, Xan wrote: The idea is behind this https://gist.github.com/2407923 But I receive: $ gdmd-4.6 algorisme_code.d algorisme_code.d:22: Error: variable

Re: .empty and .length Amend language manual?

2012-04-18 Thread bearophile
dcoder: Also, is there any surprises / difference between the two: if( !arr.length) and if( arr.empty) do they produce the same thing all the time? thanks. No surprises here, thankfully. Its implementation: https://raw.github.com/D-Programming-Language/phobos/master/std/array.d

Re: Clearly Label D1/D2/Tango/Phobos

2012-04-18 Thread H. S. Teoh
On Wed, Apr 18, 2012 at 04:15:12PM +0200, Somedude wrote: Le 18/04/2012 14:34, Paul a écrit : I bought the book and am trying to patiently learn this language. I follow various tutorials here and around the web that frequently won't compile. I suspect it has something to do with

Re: Sampling algorithms for D

2012-04-18 Thread Somedude
Le 18/04/2012 05:15, Joseph Rushton Wakeling a écrit : On 13/04/12 10:04, Dmitry Olshansky wrote: OK, I'll see what I can do. I'd like to discuss and refine the design a bit further before making any pull request -- should I take things over to the Phobos mailing list for this ... ? I'm no

Re: Compiling Was: arrays and foreach

2012-04-18 Thread SomeDude
On Tuesday, 17 April 2012 at 12:11:21 UTC, David wrote: In this case, I had to type: rdmd -unittest --main test.d Without the --main, I would get linker errors, and couldn't find the reason for these errors. Happily, someone here explained me that the effect of the --main flag was to insert a

collectExceptionMsg and emptyExceptionMsg

2012-04-18 Thread Andrej Mitrovic
Why does collectExceptionMsg return a special 'emptyExceptionMsg' string if the exception caught has no message? string collectExceptionMsg(T = Exception, E)(lazy E expression) { try { expression(); return cast(string)null; } catch(T e) return e.msg.empty

Re: Sampling algorithms for D

2012-04-18 Thread Joseph Rushton Wakeling
On 18/04/12 17:03, Somedude wrote: This looks very C++ ish. Yea, it's a rewrite of code originally in C (not even ++ ... !). I can't comment very much, being myself quite noob, but I think you can do this, for style as well as performance: - add pure nothrow everywhere you can. I think

GLUT glutCreateWindow error

2012-04-18 Thread DAS_888
When I'm trying to create GLUT Window via DMD 2.059 compilation of my code, I'm getting an error: freeglut ERROR: Internal error FBConfig with necessary capabilities not found in function fgOpenWindow X Error of failed request: BadWindow (invalid Window parameter) Major opcode of failed

Re: D-Cocoa Port

2012-04-18 Thread Jacob Carlborg
On 2012-04-18 16:39, Rizo Isrof wrote: Thank you for such a detailed overview of the existing approaches - it helped me a lot to understand the theory. As you suggested, I will probably use a modified version of the compiler for tests. But in order to fully understand the implementation details

Re: Clearly Label D1/D2/Tango/Phobos

2012-04-18 Thread Jacob Carlborg
On 2012-04-18 16:15, Somedude wrote: Hi ! It's simple: use D2, and forget about Tango. What's wrong with Tango? It works with D2 and you can have it side by side with Phobos. The XML library in Tango is superior to the one in Phobos. -- /Jacob Carlborg

Re: appending newly initialized struct to array

2012-04-18 Thread bearophile
Ali: That a thousandth time I have made that mistake and still have not learned. :( Yes, .nan may not be compared with any other value, including .nan. Today I'll present an enhancement request to remove this problem from D. Hugs, bearophile

Re: Sampling algorithms for D

2012-04-18 Thread Dmitry Olshansky
On 18.04.2012 19:03, Somedude wrote: [snip] Tweaked version, an revision of RandomSample from std.random, is available from https://github.com/WebDrake/RandomSample Feedback on code details and on tests would be very welcome. It seems about 10% slower than the original code I wrote, which I

Re: tupleof.length of a class in a template return 0

2012-04-18 Thread SomeDude
On Tuesday, 17 April 2012 at 00:04:16 UTC, Michaël Larouche wrote: My template works with a struct but when I try to mixin my template in a class, I get compile error because T.tupleof.length returns 0. Here's the whole code: http://ideone.com/UR6YU For what it's worth, dmd 2.059 (it seems

Re: appending newly initialized struct to array

2012-04-18 Thread SomeDude
On Wednesday, 18 April 2012 at 16:36:39 UTC, bearophile wrote: Ali: That a thousandth time I have made that mistake and still have not learned. :( Yes, .nan may not be compared with any other value, including .nan. Today I'll present an enhancement request to remove this problem from D.

Re: Cast Object - get null

2012-04-18 Thread Jonathan M Davis
On Wednesday, April 18, 2012 18:58:42 Namespace wrote: override bool opEquals(Object o) const { if (o is null) { return false; } writeln(o); // write: cast.Vector2D!(float).Vector2D Vector2D!(T) vec = cast(Vector2D!(T)) o; writeln(vec); // write: null // ... It seems the cast

Re: appending newly initialized struct to array

2012-04-18 Thread Jonathan M Davis
On Wednesday, April 18, 2012 19:04:12 SomeDude wrote: On Wednesday, 18 April 2012 at 16:36:39 UTC, bearophile wrote: Ali: That a thousandth time I have made that mistake and still have not learned. :( Yes, .nan may not be compared with any other value, including .nan. Today I'll

Re: collectExceptionMsg and emptyExceptionMsg

2012-04-18 Thread Jonathan M Davis
On Wednesday, April 18, 2012 17:49:55 Andrej Mitrovic wrote: Why does collectExceptionMsg return a special 'emptyExceptionMsg' string if the exception caught has no message? string collectExceptionMsg(T = Exception, E)(lazy E expression) { try { expression(); return cast(string)null;

Re: Clearly Label D1/D2/Tango/Phobos

2012-04-18 Thread Stewart Gordon
On 18/04/2012 13:34, Paul wrote: I bought the book and am trying to patiently learn this language. I follow various tutorials here and around the web that frequently won't compile. I suspect it has something to do with D1/D2/Phobos/Tango and not just really poor unvetted tutorials. It would

Re: Cast Object - get null

2012-04-18 Thread Jonathan M Davis
On Wednesday, April 18, 2012 19:15:21 Namespace wrote: one another, you're going to need to overload opCast. - Jonathan M Davis Thanks for your answer. I have tried to overload opCast in this way: U opCast(U)() const { return U(this.x, this.y); } But then i get this compiler error

Re: collectExceptionMsg and emptyExceptionMsg

2012-04-18 Thread Andrej Mitrovic
On 4/18/12, Jonathan M Davis jmdavisp...@gmx.com wrote: Probably to avoid any issues of null vs empty But what I'm saying is an empty string isn't null. It also makes it very clear that you got an empty exception message when printing the message, whereas there won't be any difference

Re: Cast Object - get null

2012-04-18 Thread Namespace
I take your first example and the relevant class part looks now like this: class Vector2D(T) { public: T x; T y; this() { } /** * */ static Vector2D!(T) opCall(U, V)(U x, V y) { Vector2D!(T) vec = new Vector2D!(T)();

Re: Cast Object - get null

2012-04-18 Thread Namespace
Sorry, U v = new U(this.x, this.y); means U v = U(this.x, this.y); I tested it with static opCall and also with a normal constructor this(T x, T y)

Re: collectExceptionMsg and emptyExceptionMsg

2012-04-18 Thread Jonathan M Davis
On Wednesday, April 18, 2012 19:32:44 Andrej Mitrovic wrote: On 4/18/12, Jonathan M Davis jmdavisp...@gmx.com wrote: Probably to avoid any issues of null vs empty But what I'm saying is an empty string isn't null. True. But by avoiding the empty string, the entire issue of null == is

Re: Sampling algorithms for D

2012-04-18 Thread Joseph Rushton Wakeling
On 18/04/12 18:54, Dmitry Olshansky wrote: I can't comment very much, being myself quite noob, but I think you can do this, for style as well as performance: - add pure nothrow everywhere you can. Yup, unless it's a template as its properties are deduced anyway. I really don't see anywhere I

Re: Cast Object - get null

2012-04-18 Thread Namespace
1. opCast doesn't do an implict cast. You'll have to cast to get == to work. 2. If you really have a static opCall, then the new isn't necessary. 3. You need to return from opCast. You're just declaring a local variable. 4. You need to import std.traits, or using Unqual will cause the

Re: T : T*

2012-04-18 Thread Stewart Gordon
On 13/04/2012 19:47, Jonathan M Davis wrote: I'd just like to verify that my understanding of T : T* in this template is correct: struct S(T : T*) snip it appears that the compiler is instead taking this to mean that the pointer part of the type should be stripped from the template argument's

Re: appending newly initialized struct to array

2012-04-18 Thread SomeDude
On Wednesday, 18 April 2012 at 18:18:44 UTC, Ali Çehreli wrote: On 04/18/2012 10:13 AM, Jonathan M Davis wrote: It's by design. An enhancement request is a waste of time. Comparisons with NaN _always_ return false regardless of what they're compared against - even NaN. It's not going to

Re: Cast Object - get null

2012-04-18 Thread Namespace
I see i must write if (vs2 == cast(Vector2s)(vf)) { writeln(equal); } That is unacceptable. Is this the only possibility? I thought that opEquals can cast this intern. It would seem that D code isn't so brief as i thought and hoped before.

Re: Cast Object - get null

2012-04-18 Thread Namespace
On Wednesday, 18 April 2012 at 19:18:42 UTC, Namespace wrote: I see i must write if (vs2 == cast(Vector2s)(vf)) { writeln(equal); } That is unacceptable. Is this the only possibility? I thought that opEquals can cast this intern. It would seem that D code isn't so brief as i thought

delegates vs functions = practical consequences

2012-04-18 Thread Xan
Hi, I want to know what is most interesting for me: delegates or functions. I consulted sources but none say the practical consequences of such election. What can I do and what can't I do with functions and delegates? Please, be didactics, I'm a newbee Thanks, Xan.

Re: File Ex from std_stdio won't compile

2012-04-18 Thread Paul
On Wednesday, 18 April 2012 at 12:42:26 UTC, simendsjo wrote: On Wed, 18 Apr 2012 14:09:20 +0200, Paul phshaf...@gmail.com wrote: I copied the code below from this site under the std.stdio library reference section and tried to compile it. I downloaded D2/Phobos. Compiler says

Re: collectExceptionMsg and emptyExceptionMsg

2012-04-18 Thread Andrej Mitrovic
On 4/18/12, Jonathan M Davis jmdavisp...@gmx.com wrote: that is null == . Wow, I don't understand this, why is comparison with null allowed with the equals operator for strings? import std.stdio; class Foo { } void main() { Foo foo; writeln(foo == null); // compile error, as it should

Newbie Introduction (was Re: arrays and foreach)

2012-04-18 Thread Paul D. Anderson
SomeDude: Your outline and especially your emphasis on what a rank beginner needs to know is very good. Would you consider writing it up yourself? Not the whole thing, maybe but the beginner info and the compiler/linker appendices. You have a commendable prose style. There are tutorials

Re: collectExceptionMsg and emptyExceptionMsg

2012-04-18 Thread Jonathan M Davis
On Wednesday, April 18, 2012 13:52:30 Jonathan M Davis wrote: On Wednesday, April 18, 2012 19:32:44 Andrej Mitrovic wrote: On 4/18/12, Jonathan M Davis jmdavisp...@gmx.com wrote: Probably to avoid any issues of null vs empty But what I'm saying is an empty string isn't null. True.

Re: Cast Object - get null

2012-04-18 Thread Jonathan M Davis
On Wednesday, April 18, 2012 20:02:32 Namespace wrote: 1. opCast doesn't do an implict cast. You'll have to cast to get == to work. 2. If you really have a static opCall, then the new isn't necessary. 3. You need to return from opCast. You're just declaring a local variable.

Re: collectExceptionMsg and emptyExceptionMsg

2012-04-18 Thread Jonathan M Davis
On Wednesday, April 18, 2012 23:52:29 Andrej Mitrovic wrote: On 4/18/12, Jonathan M Davis jmdavisp...@gmx.com wrote: that is null == . Wow, I don't understand this, why is comparison with null allowed with the equals operator for strings? import std.stdio; class Foo { } void main()

Re: Cast Object - get null

2012-04-18 Thread Namespace
4. Of course i import it, but it is implicit import if i import std.stdio. No, it doesn't. If it does, it's an import bug. std.stdio does not publicly import std.traits. You need to import it. - Jonathan M Davis Believe me, it works fine. So it must be a bug. For opCast i have now this

Re: Clearly Label D1/D2/Tango/Phobos

2012-04-18 Thread Paul
On Wednesday, 18 April 2012 at 14:15:08 UTC, Somedude wrote: Le 18/04/2012 14:34, Paul a écrit : I bought the book and am trying to patiently learn this language. I follow various tutorials here and around the web that frequently won't compile. I suspect it has something to do with

Re: learn.newbie forum

2012-04-18 Thread Paul
On Wednesday, 18 April 2012 at 14:10:17 UTC, Somedude wrote: Le 18/04/2012 14:19, Paul a écrit : I think there should be a learn.newbie forum. After I post my little problems of a sample code snippet that won't compile, I read some of the other threads. There are those c/c++ programmers

Re: delegates vs functions = practical consequences

2012-04-18 Thread John Chapman
On Wednesday, 18 April 2012 at 21:07:08 UTC, Xan wrote: Hi, I want to know what is most interesting for me: delegates or functions. I consulted sources but none say the practical consequences of such election. What can I do and what can't I do with functions and delegates? Please, be

Re: delegates vs functions = practical consequences

2012-04-18 Thread Mirko Pilger
I want to know what is most interesting for me: delegates or functions. I consulted sources but none say the practical consequences of such election. in addition to what john said: regarding _function literals_ the difference is by using a delegate instead of a function you have access to the

Re: Cast Object - get null

2012-04-18 Thread Namespace
Too early happy, now it seems opEquals wouldn't be called... I tried this again: U opCast(U)() const if (is(Unqual!U == Vector2D!byte) || is(Unqual!U == Vector2D!ubyte) || is(Unqual!U == Vector2D!short) || is(Unqual!U == Vector2D!ushort) ||

Re: learning D. Experienced issue very quickly.

2012-04-18 Thread Paul
On Wednesday, 18 April 2012 at 13:10:47 UTC, Mark wrote: Yeah I bought the book recently and ran into an issue very quickly into it. But this error I keep getting keeps bugging me. Could really use an explanation on why its not compiling. Here is the code. Mark I started a thread along

Re: delegates vs functions = practical consequences

2012-04-18 Thread Ali Çehreli
On 04/18/2012 03:50 PM, Mirko Pilger wrote: I want to know what is most interesting for me: delegates or functions. I consulted sources but none say the practical consequences of such election. in addition to what john said: regarding _function literals_ the difference is by using a

Re: appending newly initialized struct to array

2012-04-18 Thread H. S. Teoh
On Wed, Apr 18, 2012 at 08:50:10PM +0200, SomeDude wrote: On Wednesday, 18 April 2012 at 18:18:44 UTC, Ali Çehreli wrote: On 04/18/2012 10:13 AM, Jonathan M Davis wrote: It's by design. An enhancement request is a waste of time. Comparisons with NaN _always_ return false regardless of what

Re: delegates vs functions = practical consequences

2012-04-18 Thread H. S. Teoh
On Wed, Apr 18, 2012 at 11:07:07PM +0200, Xan wrote: Hi, I want to know what is most interesting for me: delegates or functions. I consulted sources but none say the practical consequences of such election. What can I do and what can't I do with functions and delegates? Please, be

Re: Clearly Label D1/D2/Tango/Phobos

2012-04-18 Thread H. S. Teoh
On Thu, Apr 19, 2012 at 12:34:09AM +0200, Paul wrote: [...] As for the example from this site under std.stdio; it should compile. It's a simple program. This is the mother site. A member helped me realize that it needs import std.stdio; // test.d void main(string args[]) { auto

Re: learning D. Experienced issue very quickly.

2012-04-18 Thread H. S. Teoh
On Thu, Apr 19, 2012 at 12:51:21AM +0200, Paul wrote: On Wednesday, 18 April 2012 at 13:10:47 UTC, Mark wrote: Yeah I bought the book recently and ran into an issue very quickly into it. But this error I keep getting keeps bugging me. Could really use an explanation on why its not compiling.

Re: appending newly initialized struct to array

2012-04-18 Thread bearophile
SomeDude: It shouldn't be a problem to detect comparisons against literal .nan values. The compiler can warn with comparison is always false. Ali Now THAT makes sense. That's what my proposal is going to be, with small refinements :-) (And it think it's not the first time someone

Re: Cast Object - get null

2012-04-18 Thread Jonathan M Davis
On Thursday, April 19, 2012 00:49:29 Namespace wrote: Too early happy, now it seems opEquals wouldn't be called... I tried this again: U opCast(U)() const if (is(Unqual!U == Vector2D!byte) || is(Unqual!U == Vector2D!ubyte) || is(Unqual!U == Vector2D!short) || is(Unqual!U ==

Re: appending newly initialized struct to array

2012-04-18 Thread Jonathan M Davis
On Wednesday, April 18, 2012 11:18:44 Ali Çehreli wrote: On 04/18/2012 10:13 AM, Jonathan M Davis wrote: On Wednesday, April 18, 2012 19:04:12 SomeDude wrote: On Wednesday, 18 April 2012 at 16:36:39 UTC, bearophile wrote: Ali: That a thousandth time I have made that mistake and still have

Re: Cast Object - get null

2012-04-18 Thread Jonathan M Davis
On Wednesday, April 18, 2012 19:43:07 Jonathan M Davis wrote: If you declare another overload of opCast: Object opCast(T)() const if(is(Unqual!T == Object)) { return this; } then it should work. Actually, this would be better: T opCast(T)() if(isImplicitlyConvertible!(typeof(this),

Re: tupleof.length of a class in a template return 0

2012-04-18 Thread Michaël.Larouche
On Wednesday, 18 April 2012 at 16:56:39 UTC, SomeDude wrote: On Tuesday, 17 April 2012 at 00:04:16 UTC, Michaël Larouche wrote: My template works with a struct but when I try to mixin my template in a class, I get compile error because T.tupleof.length returns 0. Here's the whole code:

Is this a bug in iota?

2012-04-18 Thread Brad Anderson
The following code: import std.range; void main() { auto i = iota(3); writeln(i.front, , length: , i.length); i.popFront(); writeln(i.front, , length: , i.length); i.popFront(); writeln(i.front, , length: , i.length); i.popFront();

Re: Is this a bug in iota?

2012-04-18 Thread bearophile
Brad Anderson: You can popFront() for as long as you want well passed the length. Obviously popping off the front of a zero length range isn't valid but I would have expected a range violation to occur rather than it to silently continuing the series with a wrapped around length. I think

Re: Is this a bug in iota?

2012-04-18 Thread Brad Anderson
On Thursday, 19 April 2012 at 03:37:00 UTC, bearophile wrote: Brad Anderson: You can popFront() for as long as you want well passed the length. Obviously popping off the front of a zero length range isn't valid but I would have expected a range violation to occur rather than it to silently