Re: Constructor params with same name as members

2014-10-23 Thread Shriramana Sharma via Digitalmars-d-learn
Oh OK here it is: http://dlang.org/deprecate.html#Variable%20shadowing%20inside%20functions But it says it is an error to use the feature by 2.061 and I'm using 2.066! Doesn't the scope of that deprecation cover struct members too? In general it should be like variables in inner scopes should

Re: Constructor params with same name as members

2014-10-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, October 23, 2014 11:47:04 Shriramana Sharma via Digitalmars-d-learn wrote: Oh OK here it is: http://dlang.org/deprecate.html#Variable%20shadowing%20inside%20functions But it says it is an error to use the feature by 2.061 and I'm using 2.066! Doesn't the scope of that

Re: Why do some language-defined attributes have @ and some not?

2014-10-23 Thread ketmar via Digitalmars-d-learn
On Thu, 23 Oct 2014 06:29:12 +0530 Shriramana Sharma via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I submit that the syntax for attributes should be streamlined. Shall I go and open a Bugzilla item? hehe. https://issues.dlang.org/show_bug.cgi?id=13388

Re: Why do some language-defined attributes have @ and some not?

2014-10-23 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 23 October 2014 at 00:59:26 UTC, Shriramana Sharma via Digitalmars-d- I submit that the syntax for attributes should be streamlined. Shall I go and open a Bugzilla item? No need: http://wiki.dlang.org/DIP64

Re: Why do some language-defined attributes have @ and some not?

2014-10-23 Thread via Digitalmars-d-learn
On Thursday, 23 October 2014 at 06:59:16 UTC, ketmar via Digitalmars-d-learn wrote: besides, no serious language can live without legacy. legacy is a sign of maturity. ;-) So you are basically saying that D is a teenager for whom wearing ugly make-up is a sign of maturity?

Re: Why do some language-defined attributes have @ and some not?

2014-10-23 Thread ketmar via Digitalmars-d-learn
On Thu, 23 Oct 2014 07:47:00 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 23 October 2014 at 06:59:16 UTC, ketmar via Digitalmars-d-learn wrote: besides, no serious language can live without legacy. legacy is a sign of maturity. ;-) So you are

Re: How the memory layout of global variable is reliable ?

2014-10-23 Thread Cjkp via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 20:37:43 UTC, Freddy wrote: On Wednesday, 22 October 2014 at 20:29:58 UTC, Cjkp wrote: Hello, I have an idea about a small code tool related to the application resources. It would rely on the assumption that some global variabled, sharing the same type and

Re: How the memory layout of global variable is reliable ?

2014-10-23 Thread ketmar via Digitalmars-d-learn
On Thu, 23 Oct 2014 07:55:36 + Cjkp via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I've probably badly explained the what and the why. I ask this because of this draft: http://dpaste.dzfl.pl/e15305cbc32d Tool: generate a module with some static strings. (used as

Re: Constructor params with same name as members

2014-10-23 Thread bearophile via Digitalmars-d-learn
Jonathan M Davis: Questions like this have come up and been discussed before, but using the same parameter names as member variable names for constructors is such a common practice that there would be quite a bit of screaming if we didn't allow it. I'm willing to hear them scream. D should

Patterns for functions in template parameters

2014-10-23 Thread Max Samukha via Digitalmars-d-learn
If I remember correctly, at some point a syntax was introduced for pattern-matching functions passed to templates. Something like: template Foo(B(A) foo, A, B) { } alias f = Foo!((int x) = x % 2 == 0); That would instantiate Foo with B == bool, A == int and foo bound to the lambda. The

Re: How the memory layout of global variable is reliable ?

2014-10-23 Thread Cjkp via Digitalmars-d-learn
On Thursday, 23 October 2014 at 08:04:23 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 23 Oct 2014 07:55:36 + Cjkp via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I've probably badly explained the what and the why. I ask this because of this draft:

Parsing a date string into a std.datetime.datetime

2014-10-23 Thread Colin via Digitalmars-d-learn
Hi, I'm looking for an easy way to parse a dates into a datetime object. Most of my dates will be of the form: mmm dd, HH:MM AM|PM So like: May 30, 2014 12:12 PM I can easily write a regex or whatever to pull these out of that one format, but it's not guaranteed they'll all be in the

Re: Patterns for functions in template parameters

2014-10-23 Thread Kagamin via Digitalmars-d-learn
Maybe, argument deduction? template Foo(T: T[U], U) { ... } Foo!(int[long]) // instantiates Foo with T set to int, U set to long

Re: Returning a ref to a temporary already possible?

2014-10-23 Thread Shriramana Sharma via Digitalmars-d-learn
Hi thanks for the reply. So should I understand that return this doesn't really return the ref but the object actually? Or it does return a reference but since it's assigned a name, it lives on under that name and so only the single struct object P is ever created? Otherwise one would wonder how

Re: Returning a ref to a temporary already possible?

2014-10-23 Thread ketmar via Digitalmars-d-learn
On Thu, 23 Oct 2014 16:55:52 +0530 Shriramana Sharma via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I'd really like to know what's exactly happening in that line: auto P = Pair(1, 2).handle ; object moving. add postblit (`this (this)`) and you'll see that. signature.asc

Re: Returning a ref to a temporary already possible?

2014-10-23 Thread ketmar via Digitalmars-d-learn
On Thu, 23 Oct 2014 14:36:17 +0300 ketmar via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thu, 23 Oct 2014 16:55:52 +0530 Shriramana Sharma via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I'd really like to know what's exactly happening in that line:

Re: Destructor order

2014-10-23 Thread via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 23:11:14 UTC, Ali Çehreli wrote: On 10/22/2014 04:05 PM, eles wrote: And the compiler swallows this without even barking? The compiler must obey an alias this inside Scoped. I've thinking for a way do disallow this but haven't been able to spend much time on

Re: Destructor order

2014-10-23 Thread Marco Leise via Digitalmars-d-learn
Am Thu, 23 Oct 2014 12:15:13 + schrieb Marc Schütz schue...@gmx.net: Yet another use case for borrowing. Cool, how does it keep the original struct alive though, if it isn't stored anywhere? Or will it error out when you attempt to use the dangling pointer to the object? -- Marco

Re: Constructor params with same name as members

2014-10-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/23/14 1:03 AM, Shriramana Sharma via Digitalmars-d-learn wrote: Hello. Please see the following code: import std.stdio ; struct Pair { int x, y ; this (int x, int y) { x = x ; y = y ; } } void main() { auto P = Pair(1, 2) ; writeln(P.x, ' ', P.y) ; } This

Re: Using in as a parameter qualifier

2014-10-23 Thread via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 19:44:49 UTC, Jonathan M Davis wrote: The only exception would be if the compiler determines that the lvalue in question is never used after that call, in which case, it might just move the object rather than copy it. There's an additional restriction: local

Re: Using in as a parameter qualifier

2014-10-23 Thread via Digitalmars-d-learn
On Thursday, 23 October 2014 at 05:17:14 UTC, Shriramana Sharma via Digitalmars-d-learn wrote: Hi Jonathan and thanks again for your kind replies. On 10/23/14, Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: That will result in a move operation. No copying will

Re: Destructor order

2014-10-23 Thread via Digitalmars-d-learn
On Thursday, 23 October 2014 at 13:03:08 UTC, Marco Leise wrote: Am Thu, 23 Oct 2014 12:15:13 + schrieb Marc Schütz schue...@gmx.net: Yet another use case for borrowing. Cool, how does it keep the original struct alive though, if it isn't stored anywhere? Or will it error out when you

Bug?

2014-10-23 Thread deed via Digitalmars-d-learn
// DMD v2.066.0 // All asserts pass (!) import std.math : sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh; alias F = double; immutable F a = 3, b = 5; F fmul (F a) pure { return a * b; } F fsin (F a) pure { return sin(a); } struct Smul { F value;

Re: Bug?

2014-10-23 Thread deed via Digitalmars-d-learn
-- Why bother? import std.algorithm : max; F fun (F a, F b) { return max(a,b) + 1.; } unittest { assert (gun(1, 2) == gun(2, 1)); } // Passes F pun (F a, F b) { return sin(max(a,b)); } unittest { assert (fun(1, 2) == fun(2, 1)); } // Fails // Fun, gun, pun... unittest { assert (fun(1, 2)

Re: Bug?

2014-10-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/23/14 1:08 PM, deed wrote: // DMD v2.066.0 // All asserts pass (!) Using equality is not a good idea with floating point. The compiler will on a whim, or depending on whether it can inline or not, use higher precision floats, changing the outcome slightly. I cannot say for certain

Re: Bug?

2014-10-23 Thread deed via Digitalmars-d-learn
assert (fasin(a) != fasin(a)); // ? assert (facos(a) != facos(a)); // ? Too quick there.. But: assert (fasin(0.5) != fasin(0.5)); // ? assert (facos(0.5) != facos(0.5)); // ?

parser bug?

2014-10-23 Thread Charles Hixson via Digitalmars-d-learn
The code: voidgo(ulongrecNum) {assert (buf[0] == (fh.sizeof + recNo * buf.length) 0x7f); if(dirty) yields the error message: ells$ dmd test.d test.d(78): Error: buf[0] == fh.sizeof + recNo * buf.length must be parenthesized when next to operator And I'll

Re: Bug?

2014-10-23 Thread deed via Digitalmars-d-learn
Using equality is not a good idea with floating point. The compiler will on a whim, or depending on whether it can inline or not, use higher precision floats, changing the outcome slightly. I cannot say for certain whether this explains all the issues you have, the very last one seems

Re: Patterns for functions in template parameters

2014-10-23 Thread Max Samukha via Digitalmars-d-learn
On Thursday, 23 October 2014 at 11:25:01 UTC, Kagamin wrote: Maybe, argument deduction? template Foo(T: T[U], U) { ... } Foo!(int[long]) // instantiates Foo with T set to int, U set to long Yes, but for a value template parameter. template Foo(int[long] a); { } Foo!([1: 2]); // ok,

Re: Bug?

2014-10-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/23/14 2:18 PM, deed wrote: Using equality is not a good idea with floating point. The compiler will on a whim, or depending on whether it can inline or not, use higher precision floats, changing the outcome slightly. I cannot say for certain whether this explains all the issues you have,

std.stdio breaks casting operation

2014-10-23 Thread tcak via Digitalmars-d-learn
The main function has following: - main.d - import test; auto t = new shared test.Test(); auto sock = new std.socket.TcpSocket( std.socket.AddressFamily.INET6 ); t.setIt( sock ); - test.d - module test; import std.socket; public class Test{ private

Re: parser bug?

2014-10-23 Thread anonymous via Digitalmars-d-learn
On Thursday, 23 October 2014 at 18:15:26 UTC, Charles Hixson via Digitalmars-d-learn wrote: The code: voidgo(ulongrecNum) {assert (buf[0] == (fh.sizeof + recNo * buf.length) 0x7f); if(dirty) yields the error message: ells$ dmd test.d test.d(78): Error:

Re: Bug?

2014-10-23 Thread deed via Digitalmars-d-learn
On Thursday, 23 October 2014 at 18:26:53 UTC, Steven Schveighoffer wrote: On 10/23/14 2:18 PM, deed wrote: Using equality is not a good idea with floating point. The compiler will on a whim, or depending on whether it can inline or not, use higher precision floats, changing the outcome

Re: Bug?

2014-10-23 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Oct 23, 2014 at 02:26:52PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: On 10/23/14 2:18 PM, deed wrote: [...] Now, if fun's body is { return sin(a); }, the behaviour changes to: auto c = fun(100); auto d = fun(100); assert (c == d); // Ok assert

Re: Constructor params with same name as members

2014-10-23 Thread Ali Çehreli via Digitalmars-d-learn
On 10/22/2014 11:37 PM, Jonathan M Davis wrote: x = x; which is so obviously wrong that I don't know how much of anyone could make that mistake. But simply making it illegal to assign a variable to itself would solve that problem, and that arguably should be done, since it's a essentially

Error: cannot implicitly convert expression

2014-10-23 Thread Suliman via Digitalmars-d-learn
import std.stdio; import std.conv; import std.string; import std.net.curl; void main() { string content = get(d-lang.appspot.com/testUrl2); } Error: cannot implicitly convert expression (get(d-lang.appsp ot.com/testUrl2, AutoProtocol())) of type char[] to string code from:

Re: Error: cannot implicitly convert expression

2014-10-23 Thread Suliman via Digitalmars-d-learn
Solution http://forum.dlang.org/thread/bgkklxwbhrqdhveth...@forum.dlang.org#post-l639dt:24vlj:241:40digitalmars.com Am I right understand that it's bug in doc?

Re: std.stdio breaks casting operation

2014-10-23 Thread anonymous via Digitalmars-d-learn
On Thursday, 23 October 2014 at 18:43:54 UTC, tcak wrote: Then I change the Test.setIt method as follows: import std.stdio; s = cast( typeof( s ) )sock; Error on s = cast... line: cannot cast module socket of type void to shared(Socket) Apparently std.stdio

Re: Constructor params with same name as members

2014-10-23 Thread via Digitalmars-d-learn
On Thursday, 23 October 2014 at 18:57:33 UTC, Ali Çehreli wrote: On 10/22/2014 11:37 PM, Jonathan M Davis wrote: x = x; which is so obviously wrong that I don't know how much of anyone could make that mistake. But simply making it illegal to assign a variable to itself would solve that

Re: std.stdio breaks casting operation

2014-10-23 Thread via Digitalmars-d-learn
On Thursday, 23 October 2014 at 19:20:54 UTC, anonymous wrote: On Thursday, 23 October 2014 at 18:43:54 UTC, tcak wrote: Then I change the Test.setIt method as follows: import std.stdio; s = cast( typeof( s ) )sock; Error on s = cast... line: cannot cast

Re: Constructor params with same name as members

2014-10-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 23 October 2014 at 18:57:33 UTC, Ali Çehreli wrote: On 10/22/2014 11:37 PM, Jonathan M Davis wrote: x = x; which is so obviously wrong that I don't know how much of anyone could make that mistake. But simply making it illegal to assign a variable to itself would solve that

Re: parser bug?

2014-10-23 Thread ketmar via Digitalmars-d-learn
On Thu, 23 Oct 2014 11:15:14 -0700 Charles Hixson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: The code: voidgo(ulongrecNum) {assert (buf[0] == (fh.sizeof + recNo * buf.length) 0x7f); if(dirty) yields the error message: ells$ dmd

Re: Bug?

2014-10-23 Thread deed via Digitalmars-d-learn
A similar problem was recently (about 2-3 weeks ago IIRC) seen in one of the Phobos PR's. It appears to be related to the autoextension of float to double (or double to real, I forget which) in certain contexts on Windows. @deed Could you please try to reduce the failing test to a minimal

Re: Parsing a date string into a std.datetime.datetime

2014-10-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 23 October 2014 at 11:13:26 UTC, Colin wrote: Hi, I'm looking for an easy way to parse a dates into a datetime object. Most of my dates will be of the form: mmm dd, HH:MM AM|PM So like: May 30, 2014 12:12 PM I can easily write a regex or whatever to pull these out of

Re: Error: cannot implicitly convert expression

2014-10-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 23 October 2014 at 19:18:33 UTC, Suliman wrote: Solution http://forum.dlang.org/thread/bgkklxwbhrqdhveth...@forum.dlang.org#post-l639dt:24vlj:241:40digitalmars.com Am I right understand that it's bug in doc? It certainly looks like one. std.net.curl's documentation examples

Re: Bug?

2014-10-23 Thread deed via Digitalmars-d-learn
Some testing can be found on http://dpaste.dzfl.pl/5f55f4152aa8 for both Windows and Linux. This just illustrates the sin function. Replacing double with real makes everything pass on Linux Mint 16 with -m32 and -m64. Replacing double with float seems to give the same problems as before, but

Re: Why do some language-defined attributes have @ and some not?

2014-10-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 23 October 2014 at 07:54:05 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 23 Oct 2014 07:47:00 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 23 October 2014 at 06:59:16 UTC, ketmar via Digitalmars-d-learn wrote: besides, no serious

Re: Bug?

2014-10-23 Thread anonymous via Digitalmars-d-learn
On Thursday, 23 October 2014 at 21:17:25 UTC, deed wrote: Some testing can be found on http://dpaste.dzfl.pl/5f55f4152aa8 for both Windows and Linux. This just illustrates the sin function. I think the tests marked [1] are expected to fail. They involve converting one operand of the

Re: Bug?

2014-10-23 Thread anonymous via Digitalmars-d-learn
On Thursday, 23 October 2014 at 21:42:46 UTC, anonymous wrote: On Thursday, 23 October 2014 at 21:17:25 UTC, deed wrote: Some testing can be found on http://dpaste.dzfl.pl/5f55f4152aa8 for both Windows and Linux. This just illustrates the sin function. I think the tests marked [1] are

Re: Why do some language-defined attributes have @ and some not?

2014-10-23 Thread ketmar via Digitalmars-d-learn
On Thu, 23 Oct 2014 21:33:00 + Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 23 October 2014 at 07:54:05 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 23 Oct 2014 07:47:00 + via Digitalmars-d-learn

Re: Why do some language-defined attributes have @ and some not?

2014-10-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, 23 October 2014 at 22:20:28 UTC, ketmar via Digitalmars-d-learn wrote: i love D and i want D to be widespread, but what makes me love D is it's attitude to fixing stupid legacy we have in C and C++. and now it seems to me that someone should start BetterD project to fix legacy we

classInstanceSize and vtable

2014-10-23 Thread Etienne Cimon via Digitalmars-d-learn
I'm trying to figure out the size difference between a final class and a class (which carries a vtable pointer). import std.stdio; class A { void print(){} } final class B { void print(){} } void main(){ writeln(__traits(classInstanceSize, A));

Re: classInstanceSize and vtable

2014-10-23 Thread bearophile via Digitalmars-d-learn
Etienne Cimon: I'm not sure, why does a final class carry a vtable pointer? In D all class instances contain a pointer to the class and a monitor pointer. The table is used for run-time reflection, and for standard virtual methods like toString, etc. Bye, bearophile

Re: classInstanceSize and vtable

2014-10-23 Thread Etienne Cimon via Digitalmars-d-learn
On 2014-10-23 20:12, bearophile wrote: In D all class instances contain a pointer to the class and a monitor pointer. The table is used for run-time reflection, and for standard virtual methods like toString, etc. Bye, bearophile So what's the point of making a class or methods final? Does it

Re: Why do some language-defined attributes have @ and some not?

2014-10-23 Thread Mike Parker via Digitalmars-d-learn
On 10/24/2014 7:20 AM, ketmar via Digitalmars-d-learn wrote: why can't i see that J. Random in recent discussion about deprecating prefix 'const'? the universal answer was: yes, break our code NOW! PLEASE! including people from the companies with big D codebases. There are people out there

new(malloc) locks everything in multithreading

2014-10-23 Thread tcak via Digitalmars-d-learn
This must be my special day that everything I try gets broken. import core.thread; import std.stdio; class ThreadTest{ private core.thread.Thread th; public this() shared{ th = cast( shared )( new core.thread.Thread(

Re: new(malloc) locks everything in multithreading

2014-10-23 Thread safety0ff via Digitalmars-d-learn
On Friday, 24 October 2014 at 02:51:20 UTC, tcak wrote: I don't want to blame dmd directly because as far as I see from the search I did with __lll_lock_wait_private, some C++ programs are having same problem with malloc operation as well. But still, can this be because of compiler? Looks