Re: out contract misunderstanding (was: I cannot understand problem with argument of the function)

2013-09-19 Thread Artur Skawina
On 09/19/13 20:01, Ivan Kazmenko wrote: > On Thursday, 19 September 2013 at 07:45:44 UTC, monarch_dodra wrote: >> On Thursday, 19 September 2013 at 06:39:09 UTC, Ivan Kazmenko wrote: >>> On Thursday, 19 September 2013 at 01:41:15 UTC, mrd wrote: Why argument "value" in contract isn't equal 2 ?

Re: out contract misunderstanding (was: I cannot understand problem with argument of the function)

2013-09-19 Thread Ivan Kazmenko
On Thursday, 19 September 2013 at 07:45:44 UTC, monarch_dodra wrote: On Thursday, 19 September 2013 at 06:39:09 UTC, Ivan Kazmenko wrote: On Thursday, 19 September 2013 at 01:41:15 UTC, mrd wrote: Why argument "value" in contract isn't equal 2 ? Why should it be? I actually disagree though:

Re: out contract misunderstanding (was: I cannot understand problem with argument of the function)

2013-09-19 Thread mrd
On Thursday, 19 September 2013 at 06:39:09 UTC, Ivan Kazmenko wrote: On Thursday, 19 September 2013 at 01:41:15 UTC, mrd wrote: $ ./bug body, value=2 out contract, value=0 Why argument "value" in contract isn't equal 2 ? Why should it be? value is a mutable argument, and the out contract ev

Re: out contract misunderstanding (was: I cannot understand problem with argument of the function)

2013-09-19 Thread monarch_dodra
On Thursday, 19 September 2013 at 06:39:09 UTC, Ivan Kazmenko wrote: On Thursday, 19 September 2013 at 01:41:15 UTC, mrd wrote: $ ./bug body, value=2 out contract, value=0 Why argument "value" in contract isn't equal 2 ? Why should it be? value is a mutable argument, and the out contract ev

Re: I cannot understand problem with argument of the function

2013-09-19 Thread monarch_dodra
On Wednesday, 18 September 2013 at 21:13:27 UTC, mrd wrote: This bug reproducible also without a template: http://pastebin.com/QPvCFYL1 $ ./bug works: Inside of body: value=1 type=ulong Inside of out contract: value=1 type=ulong result=[1] not works: Inside of body: value=300 type=ulong Inside

Re: out contract misunderstanding (was: I cannot understand problem with argument of the function)

2013-09-18 Thread Ivan Kazmenko
On Thursday, 19 September 2013 at 01:41:15 UTC, mrd wrote: $ ./bug body, value=2 out contract, value=0 Why argument "value" in contract isn't equal 2 ? Why should it be? value is a mutable argument, and the out contract evaluates it at the return point, which is after it's set to 0. It is

out contract misunderstanding (was: I cannot understand problem with argument of the function)

2013-09-18 Thread mrd
(new topic because old is mired in a long and clumsy source code) import std.stdio; static ubyte func( ulong value ) out( arr ) { writeln( "out contract, value=", value ); } body { writeln( "body, value=", value ); ubyte res; value >>= 7; return res; } void main

Re: I cannot understand problem with argument of the function

2013-09-18 Thread mrd
This bug reproducible also without a template: http://pastebin.com/QPvCFYL1 $ ./bug works: Inside of body: value=1 type=ulong Inside of out contract: value=1 type=ulong result=[1] not works: Inside of body: value=300 type=ulong Inside of out contract: value=2 type=ulong result=[172, 2]

Re: I cannot understand problem with argument of the function

2013-09-18 Thread mrd
On Wednesday, 18 September 2013 at 10:59:11 UTC, monarch_dodra wrote: On Wednesday, 18 September 2013 at 10:37:29 UTC, mrd wrote: Is the contract does not uses its own version of arguments? What is the point of passing earlier changed arguments into contract block? That's a good question. I'l

Re: I cannot understand problem with argument of the function

2013-09-18 Thread monarch_dodra
On Wednesday, 18 September 2013 at 10:37:29 UTC, mrd wrote: Is the contract does not uses its own version of arguments? What is the point of passing earlier changed arguments into contract block? That's a good question. I'll raise it on the main boards.

Re: I cannot understand problem with argument of the function

2013-09-18 Thread mrd
On Wednesday, 18 September 2013 at 09:56:26 UTC, monarch_dodra wrote: On Wednesday, 18 September 2013 at 09:09:29 UTC, mrd wrote: On Wednesday, 18 September 2013 at 09:07:09 UTC, mrd wrote: Looks like data corruption. Can't help you much without a full piece of code that *reproduces* the issue

Re: I cannot understand problem with argument of the function

2013-09-18 Thread monarch_dodra
On Wednesday, 18 September 2013 at 09:09:29 UTC, mrd wrote: On Wednesday, 18 September 2013 at 09:07:09 UTC, mrd wrote: Looks like data corruption. Can't help you much without a full piece of code that *reproduces* the issue (reducing it helps too). I will try to do it later. (I tried to cop

Re: I cannot understand problem with argument of the function

2013-09-18 Thread mrd
On Wednesday, 18 September 2013 at 09:09:29 UTC, mrd wrote: On Wednesday, 18 September 2013 at 09:07:09 UTC, mrd wrote: Looks like data corruption. I can not imagine what corruption was going on here: the fact that is contract gets the correct value, but the function itself - not. But they

Re: I cannot understand problem with argument of the function

2013-09-18 Thread mrd
On Wednesday, 18 September 2013 at 09:07:09 UTC, mrd wrote: Looks like data corruption. Can't help you much without a full piece of code that *reproduces* the issue (reducing it helps too). I will try to do it later. (I tried to copy these functions in a separate file - the problem is not re

Re: I cannot understand problem with argument of the function

2013-09-18 Thread mrd
On Wednesday, 18 September 2013 at 08:25:02 UTC, monarch_dodra wrote: On Wednesday, 18 September 2013 at 04:17:41 UTC, mrd wrote: (question is not about function body realisation - body just don't receives right argument value) Looks like data corruption. Can't help you much without a full pi

Re: I cannot understand problem with argument of the function

2013-09-18 Thread monarch_dodra
On Wednesday, 18 September 2013 at 04:17:41 UTC, mrd wrote: (question is not about function body realisation - body just don't receives right argument value) Looks like data corruption. Can't help you much without a full piece of code that *reproduces* the issue (reducing it helps too). For

Re: I cannot understand problem with argument of the function

2013-09-17 Thread mrd
(question is not about function body realisation - body just don't receives right argument value)

I cannot understand problem with argument of the function

2013-09-17 Thread mrd
// Simple function called for unsigned integers: static ubyte[] packVarint(T)( T value ) if( isIntegral!T && isUnsigned!T ) out( arr ) { T d; size_t size = d.unpackVarint( &arr[0] ); import std.stdio; import std.conv; writeln( "out contract, type=", typeid(T), " isUnsigned=",