Re: unicode console output

2014-04-03 Thread Denis Mezhov
Tnx, chcp 65001 and Lucida font out correct string.

Re: Why is SysTime.init invalid?

2014-04-03 Thread Jonathan M Davis
On Tuesday, April 01, 2014 03:54:07 Jonathan M Davis wrote: On Tuesday, April 01, 2014 05:35:28 ed wrote: OK, lazy me just read the std.satetime article again. It appears the design is for no invalid values and it is currently a known limitation due to CTFE. --- d_time_nan There is

Cannot access static overloaded function?

2014-04-03 Thread Domain
I have 2 modules: module A; public class A { private static void foo() {} public static void foo(int) {} } module B; import A; public class B { public static void bar() { A.foo(0); } } Error: class A.A member foo is not accessible

Re: How do I obtain the default hash of a user-defined struct

2014-04-03 Thread dnspies
On Wednesday, 2 April 2014 at 22:07:36 UTC, FreeSlave wrote: Contents of struct are compared field by field using comparison for the type of each field. Dynamic arrays are compared by contents. If you want to compare them by pointer use .ptr property. opEquals and opCmp are not about

How to find documentation of hard-to-google keywords and symbols

2014-04-03 Thread dnspies
I often have trouble finding documentation for keywords such as in and is in D. Also, functions like find I expect to be in std.string but it's actually in std.algorithm and Tuple I expect to be in std.typetuple but it's actually in std.typecons. These make sense in retrospect, but it would

Do equality checks for dynamic arrays attempt to shortcut with pointer comparison

2014-04-03 Thread dnspies
If two dynamic arrays point to the same place in memory, is it fast to compare them for equality? or does every element still have to be compared?

What does it mean for opCmp and opEquals to be consistent?

2014-04-03 Thread dnspies
To make a struct a valid key type, do I need to implement both opCmp and opEquals or just one or the other? It says on the page about associative arrays: The implementation may use either opEquals or opCmp or both. Does that mean it uses whichever one is user-defined (or both if they're both

Re: Why is SysTime.init invalid?

2014-04-03 Thread ed
On Thursday, 3 April 2014 at 06:23:40 UTC, Jonathan M Davis wrote: On Tuesday, April 01, 2014 03:54:07 Jonathan M Davis wrote: On Tuesday, April 01, 2014 05:35:28 ed wrote: OK, lazy me just read the std.satetime article again. It appears the design is for no invalid values and it is

Re: Do equality checks for dynamic arrays attempt to shortcut with pointer comparison

2014-04-03 Thread simendsjo
On 04/03/2014 09:03 AM, dnspies wrote: If two dynamic arrays point to the same place in memory, is it fast to compare them for equality? or does every element still have to be compared? Equals will first check for memory location. This is from the runtime: bool opEquals(Object lhs, Object

Re: Do equality checks for dynamic arrays attempt to shortcut with pointer comparison

2014-04-03 Thread dnspies
On Thursday, 3 April 2014 at 07:16:53 UTC, simendsjo wrote: On 04/03/2014 09:03 AM, dnspies wrote: If two dynamic arrays point to the same place in memory, is it fast to compare them for equality? or does every element still have to be compared? Equals will first check for memory location.

Re: Cannot access static overloaded function?

2014-04-03 Thread monarch_dodra
On Thursday, 3 April 2014 at 06:44:54 UTC, Domain wrote: I have 2 modules: module A; public class A { private static void foo() {} public static void foo(int) {} } module B; import A; public class B { public static void bar() { A.foo(0); } } Error: class A.A member foo is not

Re: Do equality checks for dynamic arrays attempt to shortcut with pointer comparison

2014-04-03 Thread monarch_dodra
On Thursday, 3 April 2014 at 07:03:26 UTC, dnspies wrote: If two dynamic arrays point to the same place in memory, is it fast to compare them for equality? or does every element still have to be compared? Depends how you test for equality. If you use is, the opEquals will straight up check

Re: Do equality checks for dynamic arrays attempt to shortcut with pointer comparison

2014-04-03 Thread simendsjo
On 04/03/2014 09:23 AM, dnspies wrote: On Thursday, 3 April 2014 at 07:16:53 UTC, simendsjo wrote: On 04/03/2014 09:03 AM, dnspies wrote: If two dynamic arrays point to the same place in memory, is it fast to compare them for equality? or does every element still have to be compared? Equals

Re: execute commands in the terminal OSX

2014-04-03 Thread Gary Willoughby
On Thursday, 3 April 2014 at 04:58:12 UTC, Joel wrote: It says in the Language Reference not to use system and gives other options. But the other options don't seem to work. I just have code system(clear); Try this: http://dlang.org/phobos/std_process.html#.executeShell

Re: How to find documentation of hard-to-google keywords and symbols

2014-04-03 Thread Gary Willoughby
On Thursday, 3 April 2014 at 06:59:45 UTC, dnspies wrote: I often have trouble finding documentation for keywords such as in and is in D. Also, functions like find I expect to be in std.string but it's actually in std.algorithm and Tuple I expect to be in std.typetuple but it's actually in

Re: What does it mean for opCmp and opEquals to be consistent?

2014-04-03 Thread Jonathan M Davis
On Thursday, April 03, 2014 07:10:06 dnspies wrote: To make a struct a valid key type, do I need to implement both opCmp and opEquals or just one or the other? It says on the page about associative arrays: The implementation may use either opEquals or opCmp or both. Does that mean it uses

Re: What does it mean for opCmp and opEquals to be consistent?

2014-04-03 Thread monarch_dodra
On Thursday, 3 April 2014 at 10:15:46 UTC, Jonathan M Davis wrote: _Any_ type which overloads both opEquals and opCmp and does not make them match exactly is just plain broken. I disagree: If a.opEquals(b) is true, then a.opCmp(b) must be 0. If a.opCmp(b) is non-zero, then a.opEquals(b)

Re: Sockets between D and C(++) app

2014-04-03 Thread Alexandre L.
On Wednesday, 2 April 2014 at 21:54:58 UTC, FreeSlave wrote: It's only server. Maybe problem is on client side. Yes, it is only a server which needs to answer back the client; And there was the problem: I was not fetching the client's address, and since UDP is an unconnected protocol, I

Re: What does it mean for opCmp and opEquals to be consistent?

2014-04-03 Thread w0rp
On Thursday, 3 April 2014 at 10:42:33 UTC, monarch_dodra wrote: A correctly implemented AA would use opCmp to store objects in each bucket in cases of hash collisions, but still use opEqual in case of equivalence. I would add to that, try to use opCmp if it is available. It should be

Re: CTFE error, but I have no idea what it means.

2014-04-03 Thread Kenji Hara
On Monday, 31 March 2014 at 11:51:50 UTC, Olav Lindekleiv wrote: Here's the issue: http://d.puremagic.com/issues/show_bug.cgi?id=12498 Fixed in git-head. https://github.com/D-Programming-Language/dmd/commit/2c4d8ad711ccb7c94d349830523dd500580b0130 Kenji Hara

Re: How to find documentation of hard-to-google keywords and symbols

2014-04-03 Thread dnspies
On Thursday, 3 April 2014 at 09:27:29 UTC, Gary Willoughby wrote: On Thursday, 3 April 2014 at 06:59:45 UTC, dnspies wrote: I often have trouble finding documentation for keywords such as in and is in D. Also, functions like find I expect to be in std.string but it's actually in std.algorithm

Re: Do equality checks for dynamic arrays attempt to shortcut with pointer comparison

2014-04-03 Thread dnspies
On Thursday, 3 April 2014 at 08:27:38 UTC, simendsjo wrote: On 04/03/2014 09:23 AM, dnspies wrote: On Thursday, 3 April 2014 at 07:16:53 UTC, simendsjo wrote: On 04/03/2014 09:03 AM, dnspies wrote: If two dynamic arrays point to the same place in memory, is it fast to compare them for

Re: How to find documentation of hard-to-google keywords and symbols

2014-04-03 Thread bearophile
dnspies: I still don't know where to find documentation for is (which I just found out in another forum post is overloaded for dynamic arrays). Can users overload the meaning of is themselves? Here you find info on the D language: http://dlang.org/spec.html is is an operator, so it's an

Re: What does it mean for opCmp and opEquals to be consistent?

2014-04-03 Thread dnspies
On Thursday, 3 April 2014 at 10:42:33 UTC, monarch_dodra wrote: On Thursday, 3 April 2014 at 10:15:46 UTC, Jonathan M Davis wrote: _Any_ type which overloads both opEquals and opCmp and does not make them match exactly is just plain broken. I disagree: If a.opEquals(b) is true, then

Re: How to find documentation of hard-to-google keywords and symbols

2014-04-03 Thread dnspies
On Thursday, 3 April 2014 at 16:10:45 UTC, bearophile wrote: dnspies: I still don't know where to find documentation for is (which I just found out in another forum post is overloaded for dynamic arrays). Can users overload the meaning of is themselves? Here you find info on the D

Re: How to find documentation of hard-to-google keywords and symbols

2014-04-03 Thread simendsjo
On 04/03/2014 06:31 PM, dnspies wrote: On Thursday, 3 April 2014 at 16:10:45 UTC, bearophile wrote: dnspies: I still don't know where to find documentation for is (which I just found out in another forum post is overloaded for dynamic arrays). Can users overload the meaning of is themselves?

Re: Do equality checks for dynamic arrays attempt to shortcut with pointer comparison

2014-04-03 Thread monarch_dodra
On Thursday, 3 April 2014 at 16:05:27 UTC, dnspies wrote: But I still don't see how this opEquals which takes two Objects could possibly accept dynamic arrays instead. It doesn't. The link you were given was not relevent. Object is a class-type so its instances can only be accessed by

Re: How to set JSON_TYPE in 2.0.65

2014-04-03 Thread nrgyzer
On Monday, 31 March 2014 at 19:05:11 UTC, Matt Soucy wrote: On 03/31/2014 02:59 PM, nrgyzer wrote: Hi guys, I updated my dmd version from 2.0.63 to 2.0.65 and having some trouble with my JSON-definitions. The code below worked in 2.0.63 but not in 2.0.65: JSONValue oJson = JSONValue();

Re: What does it mean for opCmp and opEquals to be consistent?

2014-04-03 Thread Steven Schveighoffer
On Thu, 03 Apr 2014 06:42:32 -0400, monarch_dodra monarchdo...@gmail.com wrote: On Thursday, 3 April 2014 at 10:15:46 UTC, Jonathan M Davis wrote: _Any_ type which overloads both opEquals and opCmp and does not make them match exactly is just plain broken. I disagree: If a.opEquals(b)

Re: How to find documentation of hard-to-google keywords and symbols

2014-04-03 Thread dnspies
On Thursday, 3 April 2014 at 16:39:02 UTC, simendsjo wrote: On 04/03/2014 06:31 PM, dnspies wrote: On Thursday, 3 April 2014 at 16:10:45 UTC, bearophile wrote: dnspies: I still don't know where to find documentation for is (which I just found out in another forum post is overloaded for

How to pass delegates to C functions?

2014-04-03 Thread Jeroen Bollen
After being downvoted on stackoverflow for no apperant reason, I figured I'd give it a shot here. How do I pass a delegate to an external C function taking a function pointer? If you want some extra rep on StackOverflow you can also answer here:

Re: How to pass delegates to C functions?

2014-04-03 Thread Justin Whear
On Thu, 03 Apr 2014 17:59:30 +, Jeroen Bollen wrote: After being downvoted on stackoverflow for no apperant reason, I figured I'd give it a shot here. How do I pass a delegate to an external C function taking a function pointer? If you want some extra rep on StackOverflow you can

Re: How to pass delegates to C functions?

2014-04-03 Thread Jeroen Bollen
On Thursday, 3 April 2014 at 18:05:26 UTC, Justin Whear wrote: On Thu, 03 Apr 2014 17:59:30 +, Jeroen Bollen wrote: After being downvoted on stackoverflow for no apperant reason, I figured I'd give it a shot here. How do I pass a delegate to an external C function taking a function

Re: How to pass delegates to C functions?

2014-04-03 Thread Adam D. Ruppe
On Thursday, 3 April 2014 at 17:59:33 UTC, Jeroen Bollen wrote: How do I pass a delegate to an external C function taking a function pointer? You can't do it directly in general, unless you can modify the C function, then you can hack around it, but a delegate and a regular function pointer

Re: How to pass delegates to C functions?

2014-04-03 Thread Jeroen Bollen
On Thursday, 3 April 2014 at 18:13:31 UTC, Adam D. Ruppe wrote: On Thursday, 3 April 2014 at 17:59:33 UTC, Jeroen Bollen wrote: How do I pass a delegate to an external C function taking a function pointer? You can't do it directly in general, unless you can modify the C function, then you

Re: What does it mean for opCmp and opEquals to be consistent?

2014-04-03 Thread monarch_dodra
On Thursday, 3 April 2014 at 16:47:05 UTC, Steven Schveighoffer wrote: On Thu, 03 Apr 2014 06:42:32 -0400, monarch_dodra monarchdo...@gmail.com wrote: On Thursday, 3 April 2014 at 10:15:46 UTC, Jonathan M Davis wrote: _Any_ type which overloads both opEquals and opCmp and does not make them

Re: What does it mean for opCmp and opEquals to be consistent?

2014-04-03 Thread Steven Schveighoffer
On Thu, 03 Apr 2014 14:45:40 -0400, monarch_dodra monarchdo...@gmail.com wrote: On Thursday, 3 April 2014 at 16:47:05 UTC, Steven Schveighoffer wrote: This can lead to false positives if opCmp(x, y) == 0 is assumed to mean equal. An example: if you used RBTree to store 2d points, and

Re: How to find documentation of hard-to-google keywords and symbols

2014-04-03 Thread simendsjo
On 04/03/2014 06:50 PM, dnspies wrote: On Thursday, 3 April 2014 at 16:39:02 UTC, simendsjo wrote: On 04/03/2014 06:31 PM, dnspies wrote: On Thursday, 3 April 2014 at 16:10:45 UTC, bearophile wrote: dnspies: I still don't know where to find documentation for is (which I just found out in

Re: How do I obtain the default hash of a user-defined struct

2014-04-03 Thread dnspies
On Wednesday, 2 April 2014 at 20:39:47 UTC, FreeSlave wrote: On Wednesday, 2 April 2014 at 20:14:31 UTC, dnspies wrote: How can I get the default-hash of a struct I've defined (to be used as part of the hash for some containing type)? UserDefined userDefined;

Re: How do I obtain the default hash of a user-defined struct

2014-04-03 Thread bearophile
dnspies: This doesn't work. It prints two different hashes for equal objects. I meant how do I get the default hash which is used by an associative array. import std.stdio; struct my_struct { int[] arr; } void main() { my_struct s1; s1.arr = [1,2,3];

two questions on enums

2014-04-03 Thread Eric
1). Is there a way to import an enum so that you don't need to qualify each instance with the type name? Something like java does with its static import. 2). It seems that you can't use an enum of struct or class type in a switch statement. This seems inconsistent. Would it make sense to

Re: two questions on enums

2014-04-03 Thread bearophile
Eric: 1). Is there a way to import an enum so that you don't need to qualify each instance with the type name? Something like java does with its static import. In some cases you can use the handy with() statement for that purpose. One example usages: final switch (foo) with (MyEnum) {

Re: two questions on enums

2014-04-03 Thread Eric
In some cases you can use the handy with() statement for that purpose. One example usages: final switch (foo) with (MyEnum) { ... } Okay - the with statement may help in some cases. I'll have to try it out... Using an enumeration of class instances isn't a good idea, they are

Re: two questions on enums

2014-04-03 Thread bearophile
Eric: I disagree. If you just think of a class type enum as a class type, then what you say makes sense. But if you instead think of it as a more powerful enum then it can enhance data safety in a program. I was speaking about the current D enum, as implemented and as designed. Regarding

Re: How do I obtain the default hash of a user-defined struct

2014-04-03 Thread dnspies
On Thursday, 3 April 2014 at 21:42:18 UTC, bearophile wrote: dnspies: This doesn't work. It prints two different hashes for equal objects. I meant how do I get the default hash which is used by an associative array. import std.stdio; struct my_struct { int[] arr; } void main() {

Re: How do I obtain the default hash of a user-defined struct

2014-04-03 Thread Steven Schveighoffer
On Thu, 03 Apr 2014 17:42:16 -0400, bearophile bearophileh...@lycos.com wrote: I have filed this big problem four years ago or more. Bug report? -Steve

Re: How do I obtain the default hash of a user-defined struct

2014-04-03 Thread bearophile
Steven Schveighoffer: Bug report? I don't remember, sorry, it's an ancient problem. Probably one of my top three D problems :-) Bye, bearophile

Re: How do I obtain the default hash of a user-defined struct

2014-04-03 Thread bearophile
dnspies: Oh so the problem isn't that that ISN'T the default hash used ... everything which is the opposite of true. You can post an elaboration of this in the main D newsgroup. Bye, bearophile

Re: two questions on enums

2014-04-03 Thread Eric
On Thursday, 3 April 2014 at 22:34:19 UTC, bearophile wrote: Eric: I disagree. If you just think of a class type enum as a class type, then what you say makes sense. But if you instead think of it as a more powerful enum then it can enhance data safety in a program. I was speaking about

How can I specify a location to write the code coverage files generated with '-cov'?

2014-04-03 Thread Saurabh Das
Hello, Say I compile a program with: dmd -unittest -debug -cov test.d Then, when I run ./test, a file 'test.lst' is generated in the current working directory. Is there a way in which I can instruct the file to be created in a separate './cov_log/' directory? Thanks, Saurabh

Re: How can I specify a location to write the code coverage files generated with '-cov'?

2014-04-03 Thread Saurabh Das
After reading some of the bug reports on BugZilla, I gather that this isn't possible yet :( Thanks, Saurabh On Friday, 4 April 2014 at 04:10:51 UTC, Saurabh Das wrote: Hello, Say I compile a program with: dmd -unittest -debug -cov test.d Then, when I run ./test, a file 'test.lst' is

Extracting Params of Templated Type

2014-04-03 Thread Nick Sabalausky
If you have a templated type, is there a way to get the compile-time parameters it was instantiated with? Ie: -- struct Foo(T) {} alias MyFoo = Foo!int; -- Is there a way to inspect MyFoo to get its T type (in this case, 'int')? *Without* actually

Re: How can I specify a location to write the code coverage files generated with '-cov'?

2014-04-03 Thread Ali Çehreli
On 04/03/2014 09:10 PM, Saurabh Das wrote: Say I compile a program with: dmd -unittest -debug -cov test.d So, that's what the makefile generates. ;) You can have an additional line that moves the coverage file away. Ali

Re: Extracting Params of Templated Type

2014-04-03 Thread Meta
On Friday, 4 April 2014 at 04:44:56 UTC, Nick Sabalausky wrote: If you have a templated type, is there a way to get the compile-time parameters it was instantiated with? Ie: -- struct Foo(T) {} alias MyFoo = Foo!int; -- Is there a way to inspect MyFoo

Re: Extracting Params of Templated Type

2014-04-03 Thread Nick Sabalausky
On 4/4/2014 1:02 AM, Meta wrote: alias TemplateArgs(T: Foo!U, U) = U; void main() { assert(is(TemplateArgs!MyFoo == int)); } Ahh thanks.

Re: How to pass delegates to C functions?

2014-04-03 Thread Mengu
On Thursday, 3 April 2014 at 17:59:33 UTC, Jeroen Bollen wrote: After being downvoted on stackoverflow for no apperant reason, I figured I'd give it a shot here. How do I pass a delegate to an external C function taking a function pointer? If you want some extra rep on StackOverflow you can

Re: How to pass delegates to C functions?

2014-04-03 Thread Jeroen Bollen
On Friday, 4 April 2014 at 05:20:42 UTC, Mengu wrote: On Thursday, 3 April 2014 at 17:59:33 UTC, Jeroen Bollen wrote: After being downvoted on stackoverflow for no apperant reason, I figured I'd give it a shot here. How do I pass a delegate to an external C function taking a function