Hi Fabio,
>Hi Gregory,
>
>It is true.
>
>But it does not justify the result.
>VFP is not multithread virtual machine, and therefore every operation is intrinsically atomic regarding the process, but the application of the parameters is not atomic
>( it is only a left to right application ).
>
>CLEAR
>
>x=1
>
>? max(incvalue(@m.x),m.x)
>
>x=1
>? max(m.x,incvalue(@m.x))
>
>PROCEDURE incvalue(v)
> v = m.v +1
> RETURN m.v-1
>endproc
>
>
>Therefore the ambiguity between passage for value or reference is not important in one called to one native function.
>
>But i cannot write NATIVEVFP(@m.MyVariable) ( this is the best solution ).
Yes, I had tried that, but it wouldn;t work
>Then, VFP VM must choice to pass the parameters by value or by reference.
>
>Example:
>
>? LEN(m.string)
>? LEN((m.string))
>
The reason it passes all by value is that the arguement can be either a single arguement or an expression. It does not test
The only means to speed it up is to write a dll (or fll) to do a len() and a stuff that does not change the size of the string, as in
=stuff(@str, ....)
>But try this:
>
>memString = SPACE(10000000)
>t1=SECONDS()
>FOR j=1 TO 100
> strLenght = LEN(m.memString+SPACE(2384))
>NEXT
>? TRANSFORM(100/(SECONDS()-m.t1),'@R string lengh = 1000000 999,999,999,999 vfops/s')
>
>t1=SECONDS()
>FOR j=1 TO 100
> strLenght = LEN(m.memString+SPACE(2385))
>NEXT
>? TRANSFORM(100/(SECONDS()-m.t1),'@R string lengh = 1000000 999,999,999,999 vfops/s')
>
>
>On my machine the second require double time !!!
>
>Then, probably VFP uses a buffer lightly larger, hoping than to be able to contain the passed parameter, but if the forecast is wrong, VFP copy the parameter an other time!
Yes, I think so too. It must allocate the blocks in 4kb length or so and m.memString+SPACE(2384) does not have to reallocate, copy, release whereas m.memString+SPACE(2385)) does
For time critical apps/functions a dll or fll is an option to consider ;-)
>Fabio
Gregory