Passing Structs to function like in C

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 13 14:03:51 PDT 2016


On 08/13/2016 09:23 PM, Engine Machine wrote:
> Then it should error if it doesn't accept ';'. If it accepts it then it
> is legal.

It is legal, yes. It's also pointless and misleading. It should be 
pointed out for the benefit of the author, as they may have a 
misconception about D syntax. It should also be pointed out so that 
others don't form such misconceptions.

[...]
> It is not a mistake... only in your mind.

In my experience, an empty declaration or statement is usually a 
mistake. And it's usually done by people coming from C. If it's not a 
mistake, it's a pretty weird style choice.

A similar thing is `return(foo);`. I'd point that out, too, because like 
the extra semicolon, it looks like it might be necessary syntax, but 
it's really just extra punctuation without purpose.

Of course, everyone is free to write their code however they want. But 
if you post here, it can't be surprising when you get feedback on it. 
Especially when it's an answer to someone else, which means it's more 
important to write good code, because you're influencing someone who's 
learning.

> If it was a mistake D wouldn't allow it.

D deliberately allows many mistakes, and they can be much more serious 
than the little style mishap at hand.

[...]
> There is no point in a lot of things, but pretending that life depends
> on such trivial things is a much worse mistake, IMO.

I originally wrote one little line on this. I don't think anyone here is 
"pretending that life depends on" it.


More information about the Digitalmars-d-learn mailing list