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

2014-04-02 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 hashing,

Cannot access static overloaded function?

2014-04-02 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: Why is SysTime.init invalid?

2014-04-02 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_na

Re: unicode console output

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

Re: template interface and delegates

2014-04-02 Thread Kenji Hara
On Tuesday, 1 April 2014 at 19:55:05 UTC, Steven Schveighoffer wrote: On Tue, 01 Apr 2014 15:47:42 -0400, anonymous wrote: Is this bug allready reported? or can somebody who has a deeper insight to this report it? I don't know. I think you should report it. If it's already reported, someon

execute commands in the terminal OSX

2014-04-02 Thread Joel
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");

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

2014-04-02 Thread FreeSlave
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 hashing, I believe. They are just operators to help when dealing with

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

2014-04-02 Thread FreeSlave
It's only server. Maybe problem is on client side. Try this if you are on Linux: //Linux C client #include #include #include #include #include #include #include int main() { int sock, res; struct sockaddr_in addr; const char* hello; size_t len; sock = socket(AF_INET,

Re: How to repeat a function call?

2014-04-02 Thread Simen Kjærås
On 2014-04-02 20:48, monarch_dodra wrote: On Wednesday, 2 April 2014 at 19:54:38 UTC, monarch_dodra wrote: On Wednesday, 2 April 2014 at 19:02:29 UTC, Simen Kjærås wrote: Better ideas, please? -- Simen I only skimmed through your post, but have you tried taking a look at adjoin? Preferably,

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

2014-04-02 Thread dnspies
Thanks, Actually I'm realizing there's a lot I'm unclear about when it comes to default comparison, equality, hashing, etc. If my struct contains a dynamic array, are the contents of the array compared by default, or just the pointers/lengths? Also, when two arrays are compared for content,

Re: How to repeat a function call?

2014-04-02 Thread monarch_dodra
On Wednesday, 2 April 2014 at 19:54:38 UTC, monarch_dodra wrote: On Wednesday, 2 April 2014 at 19:02:29 UTC, Simen Kjærås wrote: Better ideas, please? -- Simen I only skimmed through your post, but have you tried taking a look at adjoin? Preferably, the version in head? Something like "adj

Re: How to repeat a function call?

2014-04-02 Thread monarch_dodra
On Wednesday, 2 April 2014 at 19:33:28 UTC, w0rp wrote: auto initTuple(size_t N, alias func)() { string magic() { string result = "return tuple("; foreach(i; 0..N) { result ~= "func(),"; } result ~= ");"; return result; } mixin(m

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

2014-04-02 Thread FreeSlave
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; writeln(typeid(UserDefined).getHash(&userDefined)); Probably there is a better way. I don't lik

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

2014-04-02 Thread dnspies
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)?

Re: How to repeat a function call?

2014-04-02 Thread monarch_dodra
On Wednesday, 2 April 2014 at 19:02:29 UTC, Simen Kjærås wrote: Better ideas, please? -- Simen I only skimmed through your post, but have you tried taking a look at adjoin? Preferably, the version in head? Something like "adjoin!(repeat!(fun, N))" seems to natively do what you are asking

Re: How to repeat a function call?

2014-04-02 Thread w0rp
tuples are definitely a compile-time job. You could do something like this to build an N tuple by calling a function N many times. --- import std.typecons; int foo() { return 3; } auto initTuple(size_t N, alias func)() { string magic() { string result = "return tuple(";

How to repeat a function call?

2014-04-02 Thread Simen Kjærås
I'm trying to create a function that repeats a function call N times. The exact use case is generating an N-dimensional tuple: import std.typetuple; import std.typecons; template Repeat(size_t n, T...) { static if (n == 1) { alias Repeat = T; } else static if (n) { alias

Re: When this will be freed?

2014-04-02 Thread Benjamin Thaut
Am 02.04.2014 17:57, schrieb Andrea Fontana: On Wednesday, 2 April 2014 at 15:53:52 UTC, Jacob Carlborg wrote: On 2014-04-02 17:45, Andrea Fontana wrote: auto example(char* test) { return toStringz(to!string(test) ~ " world!"); } When that return string will be freed? When there is no refer

Re: When this will be freed?

2014-04-02 Thread Andrea Fontana
On Wednesday, 2 April 2014 at 15:53:52 UTC, Jacob Carlborg wrote: On 2014-04-02 17:45, Andrea Fontana wrote: auto example(char* test) { return toStringz(to!string(test) ~ " world!"); } When that return string will be freed? When there is no reference left to the string, the garbage collect

Re: When this will be freed?

2014-04-02 Thread John Colvin
On Wednesday, 2 April 2014 at 15:45:06 UTC, Andrea Fontana wrote: auto example(char* test) { return toStringz(to!string(test) ~ " world!"); } When that return string will be freed? What about: extern(C) auto example() ? to!string allocates on the GC heap when given a char* (it has to

Re: When this will be freed?

2014-04-02 Thread Jacob Carlborg
On 2014-04-02 17:45, Andrea Fontana wrote: auto example(char* test) { return toStringz(to!string(test) ~ " world!"); } When that return string will be freed? When there is no reference left to the string, the garbage collector is free to collect it when it chooses to. What about: extern(

When this will be freed?

2014-04-02 Thread Andrea Fontana
auto example(char* test) { return toStringz(to!string(test) ~ " world!"); } When that return string will be freed? What about: extern(C) auto example() ?

Re: unicode console output

2014-04-02 Thread Jos van Uden
On 2-4-2014 15:38, Denis Mezhov wrote: On Wednesday, 2 April 2014 at 12:51:57 UTC, bearophile wrote: Denis Mezhov: How to out unicode cyrillic string to console? Try this command on the command line: chcp 65001 Bye, bearophile chcp 65001 dont'work start.bat mode con cols=150 lines=50

Re: unicode console output

2014-04-02 Thread Denis Mezhov
On Wednesday, 2 April 2014 at 12:51:57 UTC, bearophile wrote: Denis Mezhov: How to out unicode cyrillic string to console? Try this command on the command line: chcp 65001 Bye, bearophile chcp 65001 dont'work start.bat mode con cols=150 lines=50 chcp 65001 %Path%\Minesweeper\Debug\Mi.e

Re: core.atomic and -profile switch

2014-04-02 Thread bearophile
Saurabh Das: I see. I wasn't sure - hence I asked. https://d.puremagic.com/issues/show_bug.cgi?id=11471 In general, how do I check if this is a known issue? Search in Bugzilla and/or ask to people. Bye, bearophile

Re: core.atomic and -profile switch

2014-04-02 Thread Saurabh Das
I see. I wasn't sure - hence I asked. In general, how do I check if this is a known issue? Thanks, Saurabh On Wednesday, 2 April 2014 at 11:19:16 UTC, bearophile wrote: Saurabh Das: With error: /usr/include/dmd/druntime/import/core/atomic.d(910): Error: asm statements are assumed to throw

Re: unicode console output

2014-04-02 Thread MGW
On Wednesday, 2 April 2014 at 12:47:06 UTC, Denis Mezhov wrote: I'm trying out to windows console unicode latin string writeln("aaabbb"); console out: aaabbb trying out to console unicode cyrillic string writeln("бббггг"); console out: ╨│╨│╨│╨▒╨▒╨▒ How to out unicode cyrillic string to console

Re: unicode console output

2014-04-02 Thread bearophile
Denis Mezhov: How to out unicode cyrillic string to console? Try this command on the command line: chcp 65001 Bye, bearophile

unicode console output

2014-04-02 Thread Denis Mezhov
I'm trying out to windows console unicode latin string writeln("aaabbb"); console out: aaabbb trying out to console unicode cyrillic string writeln("бббггг"); console out: ╨│╨│╨│╨▒╨▒╨▒ How to out unicode cyrillic string to console?

Re: Signature of main [was Sockets between D and C(++) app]

2014-04-02 Thread Ola Fosheim Grøstad
On Wednesday, 2 April 2014 at 08:55:23 UTC, Russel Winder wrote: The real signature of main in C/C++ is, I believe: int main(int, char**, char**) I believe in C it is: int main(void) int main(int,char**) or implementation defined (e.g. the third env pointer in the main signature fro

Re: Signature of main [was Sockets between D and C(++) app]

2014-04-02 Thread Andrej Mitrovic
On 4/2/14, Dicebot wrote: > D main != C main, latter is implemented in D runtime to call the > former. 0 will be also returned by latter, not the former. Actually, the compiler injects a return statement in D's main. It generates the actual C main function (unless WinMain/DllMain is provided), w

Re: Signature of main [was Sockets between D and C(++) app]

2014-04-02 Thread Dicebot
On Wednesday, 2 April 2014 at 08:55:23 UTC, Russel Winder wrote: On Wed, 2014-04-02 at 00:34 +, bearophile wrote: Alexandre L.: > int main(string[] args) > { If you don't need args, then I suggest to not put it as main argument. So probably this is better (note no int nor return, in D

Re: Signature of main [was Sockets between D and C(++) app]

2014-04-02 Thread bearophile
Russel Winder: what is the real signature in D? The _real_ signature of main() is flexible, you can use: void main() int main(in string[] args) pure nothrow D allows you to omit the args if you don't need them, returns 0 if you don't it, and it can be pure/nothrow/@safe as desired. Perh

Re: core.atomic and -profile switch

2014-04-02 Thread bearophile
Saurabh Das: With error: /usr/include/dmd/druntime/import/core/atomic.d(910): Error: asm statements are assumed to throw Is there a workaround for this? I have a decent sized codebase which I wish to profile for hotspots - but it won't compile with '-profile'. Isn't this a recent regressi

core.atomic and -profile switch

2014-04-02 Thread Saurabh Das
Hello For this test program ('test.d'): import core.atomic; int func1(shared int a) { return atomicLoad(a); } These invocations of dmd succeed: 1. dmd -main test.d 2. dmd -main -debug test.d 3. dmd -main -release test.d But this one fails: dmd -main -profile test.d With error: /usr/includ

Re: Trying Multiple Aggregate reduce

2014-04-02 Thread monarch_dodra
On Wednesday, 2 April 2014 at 09:25:53 UTC, Nordlöw wrote: so happens to support this. So I added your code to the test cases: Great! BTW: Why is static qualifier needed on definition of minmaxElement() in the unittest? Whenever you declare something in a nested context, it may or may not

Re: Trying Multiple Aggregate reduce

2014-04-02 Thread Nordlöw
so happens to support this. So I added your code to the test cases: Great! BTW: Why is static qualifier needed on definition of minmaxElement() in the unittest?

Re: Signature of main [was Sockets between D and C(++) app]

2014-04-02 Thread Russel Winder
On Wed, 2014-04-02 at 00:34 +, bearophile wrote: > Alexandre L.: > > int main(string[] args) > > { > > If you don't need args, then I suggest to not put it as main > argument. So probably this is better (note no int nor return, in > D they are not needed): > > void main() { > ... > } I am