Re: Learning D

2013-06-06 Thread H. S. Teoh
On Fri, Jun 07, 2013 at 01:01:54AM +0200, bearophile wrote: > H. S. Teoh: > > >The way to improve your coding skills is just to write > >lots and lots of code. The more you write, the better > >you'll get at it. > > Doing lot of exercise is not nearly enough. You also must do them > "smartly". An

Re: Learning D

2013-06-06 Thread bearophile
H. S. Teoh: The way to improve your coding skills is just to write lots and lots of code. The more you write, the better you'll get at it. Doing lot of exercise is not nearly enough. You also must do them "smartly". And it's far from obvious what that means. And most schools, movies, TV and

Re: Learning D

2013-06-06 Thread H. S. Teoh
On Thu, Jun 06, 2013 at 10:50:05PM +0200, Daemon wrote: > Hi there. I am mesmerized by D and I would love to start using it to > really learn programming. I've tried it a year ago but failed > miserably and went back to C#. The problem I have is that I've been > using C# and I feel it left me cripp

Re: Learning D

2013-06-06 Thread Ali Çehreli
On 06/06/2013 01:50 PM, Daemon wrote: > I am mesmerized by D and I would love to start using it to really learn > programming. I agree with bearophile. I think D is easier to learn than C++. > I decided that it would probably be best to start learning C++ and then, > when I have solid understan

Re: geting stack trace from signal handlers

2013-06-06 Thread Timothee Cour
just to be clear, this is what i get: 0 test_stacktrace_sigint 0x000102e2f69f handleTermination + 35 1 libsystem_c.dylib 0x7fff919d794a _sigtramp + 26 2 ??? 0x0005 0x0 + 5 3 test_stacktrace_sigint

Re: geting stack trace from signal handlers

2013-06-06 Thread Timothee Cour
Great! two issues (on OSX at least): A) it seems the top-most element of the call stack gets chopped off; eg in your code, the main_module.main symbol will not appear in the stack trace. Any idea why or how to fix that? Is that some inlining issue ? I tried with dmd -g, or -gs or -gc. This can be

Re: Learning D

2013-06-06 Thread bearophile
Daemon: Thanks for any responses Let's see. Your post is not longwinded. You don't need to learn C++ to learn D. On the other hand C++ has more books and free documentation around. But I think learning C++ is harder than D, because D is meant to be cleaned up compared to C++. Today if you k

Learning D

2013-06-06 Thread Daemon
Hi there. I am mesmerized by D and I would love to start using it to really learn programming. I've tried it a year ago but failed miserably and went back to C#. The problem I have is that I've been using C# and I feel it left me crippled. I don't understand a lot of the 'mechanical stuff', lik

Re: Traits and UDAs

2013-06-06 Thread Dicebot
On Thursday, 6 June 2013 at 17:50:08 UTC, Chris Williams wrote: ... It will work if use "enum" instead of "auto" for storing attribute tuple. If compile-time value is needed you almost always want to store it in enum.

Re: Traits and UDAs

2013-06-06 Thread Adam D. Ruppe
Here's how I do it: enum Dump; // just a type, no value here template Dumper(T) { void dump() { foreach (mem; __traits(allMembers, T)) { // loop over the attrs instead of try to store them in a var foreach(attr; __traits(getAttributes, __traits(getMember, T, mem)))

Traits and UDAs

2013-06-06 Thread Chris Williams
I decided to write up a little application to test using User Defined Attributes and have one question. Here is a working application that allows me to mark certain members of a function to be dumped: import std.stdio; enum Dump = "Dump"; template Dumper(T) { void dump() {

Re: geting stack trace from signal handlers

2013-06-06 Thread nazriel
On Wednesday, 5 June 2013 at 21:05:53 UTC, Timothee Cour wrote: how do i get a stacktrace inside handleTermination? If not currently possible, could we have a compile flag that would enable this kind of feature? (making code slower would be OK, its an opt in feature) Ideally we'd also be able

Re: Is the -property compiler flag broken/bad idea?

2013-06-06 Thread nazriel
On Wednesday, 5 June 2013 at 18:09:30 UTC, Gary Willoughby wrote: I've been using the -property compiler flag when i compile programs and thought it was pretty cool but i've recently had a conversation with someone who has informed me it's broken and a bad idea. Never, ever, ever use -propert

Re: Statistical aggregator

2013-06-06 Thread Joseph Rushton Wakeling
On 06/06/2013 04:05 PM, Joseph Rushton Wakeling wrote: > real _max = real.min; ... should be tweaked to real _max = real.min_normal; according to the deprecation list: http://dlang.org/deprecate.html#.min%20property%20for%20floating%20point%20types

Statistical aggregator

2013-06-06 Thread Joseph Rushton Wakeling
Hi all, In case it's useful to anyone, here's a little statistical aggregator I put together (source file attached). This is for online calculation of statistical quantities and incidentally offers an efficient way to calculate standard deviation in a single pass over data, using the algorithm de

Re: Is the -property compiler flag broken/bad idea?

2013-06-06 Thread Steven Schveighoffer
On Wed, 05 Jun 2013 17:36:11 -0400, Jonathan M Davis wrote: Strict property enforcement is as good as dead. -property is still there for the moment, but its days are numbered. Walter and Andrei pretty much consider @property to have been a failure and seem to want to get rid of @property

Re: Is the -property compiler flag broken/bad idea?

2013-06-06 Thread John Colvin
On Wednesday, 5 June 2013 at 22:25:21 UTC, Adam D. Ruppe wrote: 3) prop += 5 and friends This is the biggest deal for me. Being able to write all these read-modify-write operators on properties would simplify writing transparent wrapper types so much.

Re: Is the -property compiler flag broken/bad idea?

2013-06-06 Thread Diggory
On Thursday, 6 June 2013 at 10:38:27 UTC, Martin Primer wrote: What would be good is: @property int foo { get() { _val = value; } set() { value = _val; } } usage: foo = 12; int bar = foo; my 2 cents. That's both much more limited and longer than the current

Re: Is the -property compiler flag broken/bad idea?

2013-06-06 Thread Martin Primer
What would be good is: @property int foo { get() { _val = value; } set() { value = _val; } } usage: foo = 12; int bar = foo; my 2 cents.

Re: Is the -property compiler flag broken/bad idea?

2013-06-06 Thread Diggory
On Thursday, 6 June 2013 at 00:56:22 UTC, Adam D. Ruppe wrote: On Thursday, 6 June 2013 at 00:08:31 UTC, Jonathan M Davis wrote: Which is essentially the position of weak property enforcement. Yes, though I wish we would stop calling it 'enforcement' because nothing actually needs to be espec

Re: Global extern(C) in druntime header files?

2013-06-06 Thread Gary Willoughby
You are passing a function pointer to a C library, where it will be expected that the function uses the C calling convention. So you have to declare the function as extern(C), otherwise DMD will not compile it as such. That can cause segfaults. Right ok thanks.