Re: What is going on in this code?

2016-04-15 Thread Jonathan M Davis via Digitalmars-d
On Friday, April 15, 2016 21:16:44 Jonathan M Davis via Digitalmars-d wrote: > On Thursday, April 14, 2016 09:31:25 Steven Schveighoffer via Digitalmars-d > > wrote: > > That is awful. > > > > I propose we make slicing such a return value implicitly an error. I > > can't think of a valid reason

Re: What is going on in this code?

2016-04-15 Thread Jonathan M Davis via Digitalmars-d
On Thursday, April 14, 2016 09:31:25 Steven Schveighoffer via Digitalmars-d wrote: > That is awful. > > I propose we make slicing such a return value implicitly an error. I > can't think of a valid reason for allowing it. > > I'm not the only one: https://issues.dlang.org/show_bug.cgi?id=12625

Re: What is going on in this code?

2016-04-14 Thread Meta via Digitalmars-d
On Thursday, 14 April 2016 at 13:31:25 UTC, Steven Schveighoffer wrote: That is awful. I propose we make slicing such a return value implicitly an error. I can't think of a valid reason for allowing it. I'm not the only one: https://issues.dlang.org/show_bug.cgi?id=12625 -Steve

Re: What is going on in this code?

2016-04-14 Thread Daniel Kozak via Digitalmars-d
On Thursday, 14 April 2016 at 13:30:42 UTC, Daniel Kozak wrote: On Thursday, 14 April 2016 at 13:08:56 UTC, Carlin wrote: On Thursday, 14 April 2016 at 10:29:43 UTC, ag0aep6g wrote: [...] Thanks, that works perfectly! I couldn't figure it out and I knew I had to be missing something really

Re: What is going on in this code?

2016-04-14 Thread Steven Schveighoffer via Digitalmars-d
On 4/14/16 6:29 AM, ag0aep6g wrote: On 14.04.2016 12:14, Carlin wrote: import std.stdio; import std.bitmanip; ubyte[] serialize(uint t) { ubyte[] bytes = nativeToBigEndian(t); return bytes; } void main() { writeln(serialize(0)); } Your code is wrong. It's really easy to get

Re: What is going on in this code?

2016-04-14 Thread Daniel Kozak via Digitalmars-d
On Thursday, 14 April 2016 at 13:08:56 UTC, Carlin wrote: On Thursday, 14 April 2016 at 10:29:43 UTC, ag0aep6g wrote: [...] Thanks, that works perfectly! I couldn't figure it out and I knew I had to be missing something really basic. I still don't understand though why it works in release

Re: What is going on in this code?

2016-04-14 Thread Carlin via Digitalmars-d
On Thursday, 14 April 2016 at 10:29:43 UTC, ag0aep6g wrote: On 14.04.2016 12:14, Carlin wrote: import std.stdio; import std.bitmanip; ubyte[] serialize(uint t) { ubyte[] bytes = nativeToBigEndian(t); return bytes; } void main() { writeln(serialize(0)); } Your code is wrong.

Re: What is going on in this code?

2016-04-14 Thread ag0aep6g via Digitalmars-d
On 14.04.2016 12:14, Carlin wrote: import std.stdio; import std.bitmanip; ubyte[] serialize(uint t) { ubyte[] bytes = nativeToBigEndian(t); return bytes; } void main() { writeln(serialize(0)); } Your code is wrong. It's really easy to get wrong, though. Too easy probably.

What is going on in this code?

2016-04-14 Thread Carlin via Digitalmars-d
I have encountered a weird error that only seems to occur when building in debug mode. In release everything works fine. I wanted to post here before raising a new issue in case I'm just horribly blind at what is happening here. --- import std.stdio; import std.bitmanip; ubyte[]