Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-14 Thread Ellery Newcomer via Digitalmars-d-learn
On Saturday, 14 March 2015 at 23:57:33 UTC, weaselcat wrote: On Saturday, 14 March 2015 at 23:46:28 UTC, Ellery Newcomer wrote: And C# has LINQ, which when combined with the last point is fricken awesome. what does LINQ offer that UFCS-style functional programming does not? LINQ basically

mixin template can't contain statements: workaround?

2015-03-14 Thread Timothee Cour via Digitalmars-d-learn
Why can't we allow mixin templates to contain statements, as is the case for regular mixins? Is there a workaround? here's a dummy example: template mixin Foo{ //some statement, eg: 'return;' } void fun(){ mixin Foo; } Note that I can do this with a regular mixin, but template mixins are

Re: OutputDebugString()

2015-03-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, March 14, 2015 17:49:10 Robert M. Münch via Digitalmars-d-learn wrote: Now, just need to check why I don't see any debug output but that's not a DMD issue ;-). In case you didn't know, if you're not running the program in visual studio, you should see the output in in DebugView:

Re: Garbage collector returning pointers

2015-03-14 Thread via Digitalmars-d-learn
On Saturday, 14 March 2015 at 18:26:34 UTC, Robert M. Münch wrote: Hi, I have a question about how the GC handles this case: export extern(C) char* foo(){ char[] x = This is a dynamic D string..dup; return(cast(char*)x); } Since x is pointer to array data length if it goes out of scope,

Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-14 Thread weaselcat via Digitalmars-d-learn
On Saturday, 14 March 2015 at 23:46:28 UTC, Ellery Newcomer wrote: And C# has LINQ, which when combined with the last point is fricken awesome. what does LINQ offer that UFCS-style functional programming does not?

Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-14 Thread Meta via Digitalmars-d-learn
On Sunday, 15 March 2015 at 00:56:24 UTC, Ellery Newcomer wrote: On Saturday, 14 March 2015 at 23:57:33 UTC, weaselcat wrote: On Saturday, 14 March 2015 at 23:46:28 UTC, Ellery Newcomer wrote: And C# has LINQ, which when combined with the last point is fricken awesome. what does LINQ offer

Re: mixin template can't contain statements: workaround?

2015-03-14 Thread Meta via Digitalmars-d-learn
On Sunday, 15 March 2015 at 01:20:55 UTC, Timothee Cour wrote: Why can't we allow mixin templates to contain statements, as is the case for regular mixins? Is there a workaround? here's a dummy example: template mixin Foo{ //some statement, eg: 'return;' } void fun(){ mixin Foo; } Note

Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-14 Thread Ellery Newcomer via Digitalmars-d-learn
On Saturday, 14 March 2015 at 13:52:13 UTC, Craig Dillabaugh wrote: I don't have any C# experience so I can't compare those languages much, but I've heard people say their are D / C# similarities. Anyway, this isn't a criticism of your comment, I was just curious what (other than the

Re: embedding Pyd in Windows program

2015-03-14 Thread Matt via Digitalmars-d-learn
On Saturday, 14 March 2015 at 00:28:59 UTC, Ellery Newcomer wrote: On Friday, 13 March 2015 at 19:05:59 UTC, Matt wrote: example code, see if I can figure it out, but if you can advise, that would be fantastic. Thank you for all the help so far, it's really been appreciated My penitence for

Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-14 Thread dnewer via Digitalmars-d-learn
On Saturday, 14 March 2015 at 09:59:05 UTC, dnewer wrote: yes,java is good lang,but i dont think it's better than c#,if no oracle or google support java will less and less. C# is a good and easy lang. i like C# . but,C# cant compiled to native code. So far, I have been searching for a

Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-14 Thread bearophile via Digitalmars-d-learn
dnewer: but,C# cant compiled to native code. Soon you will be able to compile C# natively. Bye, bearophile

Dlang seems like java now,but why not let d more like C# Style?

2015-03-14 Thread dnewer via Digitalmars-d-learn
yes,java is good lang,but i dont think it's better than c#,if no oracle or google support java will less and less. C# is a good and easy lang. i like C# . but,C# cant compiled to native code. So far, I have been searching for a language, like c # write efficiency, but more secure than that of

Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-14 Thread dnewer via Digitalmars-d-learn
On Saturday, 14 March 2015 at 10:04:15 UTC, bearophile wrote: dnewer: but,C# cant compiled to native code. Soon you will be able to compile C# natively. Bye, bearophile i know some thing about .net native. but its too late.i dont think microsoft will rranslate all libiary to native. and

Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-14 Thread Craig Dillabaugh via Digitalmars-d-learn
On Saturday, 14 March 2015 at 09:59:05 UTC, dnewer wrote: yes,java is good lang,but i dont think it's better than c#,if no oracle or google support java will less and less. C# is a good and easy lang. i like C# . but,C# cant compiled to native code. So far, I have been searching for a

Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-14 Thread ketmar via Digitalmars-d-learn
On Sat, 14 Mar 2015 10:08:23 +, dnewer wrote: and even c# can be compile natively. i dont think C# will support to can be used to write a driver! and you just don't need to write drivers. signature.asc Description: PGP signature

Re: get struct member names

2015-03-14 Thread Charles Cooper via Digitalmars-d-learn
Wow, this is f***ing cool. http://dlang.org/traits.html#allMembers Thank you! On Saturday, 14 March 2015 at 14:54:27 UTC, Adam D. Ruppe wrote: __traits(allMembers, Struct) can do it. Get the free sample chapter from my book: https://www.packtpub.com/application-development/d-cookbook and it

'strong types' a la boost

2015-03-14 Thread Charles Cooper via Digitalmars-d-learn
I was wondering what the idiomatic D way of implementing strong types. Boost has something along these lines using classes: http://www.boost.org/doc/libs/1_37_0/boost/strong_typedef.hpp When programming in C++ I find that the compiler does not necessarily generate good code with these types,

get struct member names

2015-03-14 Thread Charles Cooper via Digitalmars-d-learn
Hi all, I am new to D and so far it is really great. I am wondering how to get the names of member variables in a struct or class. I haven't worked it out yet but this would enable metaprogramming like iterating over the members of the struct. I see in std.traits that you can get get

Re: 'strong types' a la boost

2015-03-14 Thread Namespace via Digitalmars-d-learn
You can do it this way: struct dollars_t { uint _dollar; this(uint d) { _dollar = d; } alias _dollar this; } struct cents_t { uint _cent; this(uint c) { _cent = c; } alias _cent this; } void do_something_with_dollars(dollars_t d) {

Re: OutputDebugString()

2015-03-14 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-03-13 21:19:07 +, Adam D. Ruppe said: In the file you want to use it, you can just write extern(Windows) void OutputDebugStringA(in char*); and it should work... or whatever the signature is, check msdn, and remember the ones that take strings tend to need A or W for the ascii

Re: 'strong types' a la boost

2015-03-14 Thread Charles Cooper via Digitalmars-d-learn
Interesting. I think in the second example there are pathological cases where one has similar declarations in two modules at the same line. moduleA.d:100 alias dollars_t TypeDef!int; moduleB.d:100 alias cents_t TypeDef!int; main.d: import moduleA; import moduleB; void

Re: get struct member names

2015-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
__traits(allMembers, Struct) can do it. Get the free sample chapter from my book: https://www.packtpub.com/application-development/d-cookbook and it goes into more detail (I'm in a bit of a rush right now!) the sample link is under the picture

Re: embedding Pyd in Windows program

2015-03-14 Thread Ellery Newcomer via Digitalmars-d-learn
On Saturday, 14 March 2015 at 07:28:04 UTC, Matt wrote: Yeah, dub is what I'm using. Actually, I made a mistake regarding the py_eval. I'm including the pyd modules in a module other than the one that has my main() function, so they weren't visible. I feel like a proper idiot for that one..

Re: 'strong types' a la boost

2015-03-14 Thread Charles Cooper via Digitalmars-d-learn
I think I may have answered my own question. It seems std.typecon provides a facility for this. http://dlang.org/phobos/std_typecons.html#.Proxy http://dlang.org/phobos/std_typecons.html#.Typedef Is this the 'right' way to do things? It seems that Proxy is used as a mixin whereas Typedef is

Re: 'strong types' a la boost

2015-03-14 Thread Namespace via Digitalmars-d-learn
On Saturday, 14 March 2015 at 16:55:09 UTC, Charles Cooper wrote: Interesting. I think in the second example there are pathological cases where one has similar declarations in two modules at the same line. Yes, that right, I've kept it simple, but of course it is not complete safe. :)

Re: 'strong types' a la boost

2015-03-14 Thread Brad Anderson via Digitalmars-d-learn
On Saturday, 14 March 2015 at 15:45:30 UTC, Charles Cooper wrote: I think I may have answered my own question. It seems std.typecon provides a facility for this. http://dlang.org/phobos/std_typecons.html#.Proxy http://dlang.org/phobos/std_typecons.html#.Typedef Is this the 'right' way to do

Garbage collector returning pointers

2015-03-14 Thread Robert M. Münch via Digitalmars-d-learn
Hi, I have a question about how the GC handles this case: export extern(C) char* foo(){ char[] x = This is a dynamic D string..dup; return(cast(char*)x); } Since x is pointer to array data length if it goes out of scope, it's destroyed and the last reference to the array data is gone.

Re: Garbage collector returning pointers

2015-03-14 Thread anonymous via Digitalmars-d-learn
On Saturday, 14 March 2015 at 18:26:34 UTC, Robert M. Münch wrote: Hi, I have a question about how the GC handles this case: export extern(C) char* foo(){ char[] x = This is a dynamic D string..dup; return(cast(char*)x); } Returning `x.ptr` would look a little nicer. Since x is pointer