Closed Karl1155 closed 5 years ago
Karl, This MEMVAR area is a bit of a challenge.
Hi Robert,
i´ve also tried the other RELEASE commands:
PUBLIC gc1, gc2
PRIVATE p1, p2, x1
gc1 := "gc1"
gc2 := "gc2"
p1 := "p1"
p2 := "p2"
x1 := "x1"
RELEASE ALL LIKE p*
RELEASE ALL LIKE g*
RELEASE ALL EXCEPT p2
The behaviour of these commands is the same as VO shows. PUBLICs are not touched, only the PRIVATE values are changed to NIL. But Foxpro would "destroy" the PRIVATES and the PUBLICs instead. Because a single RELEASE <cVar>, ...
currently "destroys" PRIVATES and PUBLICS shouldn´t the RELEASE ALL xxx commands behave the same - because we are currently in the Foxpro mode ;-) ?
Very strange is the result of the command:
RELEASE ALL
it´s translated to:
_MXRELEASE("ALL" )
When I look at the order of the memvar.xh content, it seems that in this case the precompiler simply picks up the very first RELEASE command:
...
#command CLEAR MEMORY => _MClear()
#command RELEASE <vars,...> => _MXRelease( <"vars"> )
#command RELEASE ALL => _MRelease("*", TRUE)
#command RELEASE ALL LIKE <skel> => _MRelease( #<skel>, TRUE )
#command RELEASE ALL EXCEPT <skel> => _MRelease( #<skel>, FALSE )
...
Tomorrow i'll take a look at the SAVE and RESTORE commands and report back again when there are problems.
regards Karl-Heinz
Mmm, That looks like either a bug in the PP definition or in the PP itself. I'll check
Maybe you can look at the source of the MEMVAR support and suggest a fix. I'm quite busy now with other things. It's in https://github.com/X-Sharp/XSharpPublic/blob/feature/Runtime/Runtime/XSharp.RT/Types/MemVar.prg and https://github.com/X-Sharp/XSharpPublic/blob/feature/Runtime/Runtime/XSharp.RT/Functions/MemVar.prg
and the save/restore stuff is in
Robert,
I post some results to be sure that they don´t get lost ;-)
i made some test to see how PRIVATEs - with the same name and declared in different areas - are released . Below are the VO,X#, CLIPPER and Foxpro results. From what i see, FP, CLIPPER and VO behave in all 4 scenarios the same. The only difference is that FP destroys a PRIVATE while the other two assign NIL. As you see X# does too much in the scenario 2 and 3.
FUNCTION Start() AS VOID
PRIVATE p1, p2
p1:= "p1 Start()"
p2:= "p2 Start()"
Test2()
?
? "p1 Start():" , p1
? "p2 Start():" , p2
?
RETURN
PROCEDURE Test2
PRIVATE p1, p2
p1 := "p1 Test2()"
p2 := "p2 Test2()"
Test3()
?
? "p1 Test2():" , p1
? "p2 Test2():" , p2
?
RETURN
PROCEDURE Test3
PRIVATE p1, p2
p1 := "p1 Test3()"
p2 := "p2 Test3()"
// RELEASE ALL LIKE p*
_MRelease( "p*" , TRUE )
?
? "p1 Test3():" , p1
? "p2 Test3():" , p2
?
RETURN
// -- VO + X# + Foxpro + clipper -----
p1 Test3(): NIL // FP destroys the memvar p1 instead
p2 Test3(): NIL // FP destroys the memvar p2 instead
p1 Test2(): p1 Test2()
p2 Test2(): p2 Test2()
p1 Start(): p1 Start()
p2 Start(): p2 Start()
// -- Foxpro + VO + clipper --
p1 Test3(): p1 Test3()
p2 Test3(): p2 Test3()
p1 Test2(): p1 Test3()
p2 Test2(): p2 Test3()
p1 Start(): p1 Start()
p2 Start(): p2 Start()
// ----- X# ---------
p1 Test3(): NIL
p2 Test3(): NIL
p1 Test2(): NIL
p2 Test2(): NIL
p1 Start(): p1 Start()
p2 Start(): p2 Start()
// ---- VO + Foxpro + clipper -----
p1 Test3(): p1 Test3()
p2 Test3(): p2 Test3()
p1 Test2(): p1 Test3()
p2 Test2(): p2 Test3()
p1 Start(): p1 Test3()
p2 Start(): p2 Test3()
// ---- X# ----------
p1 Test3(): NIL
p2 Test3(): NIL
p1 Test2(): NIL
p2 Test2(): NIL
p1 Start(): NIL
p2 Start(): NIL
// --- VO + Foxpro + X# + clipper -----
p1 Test3(): NIL // NOTE: FP destroys the memvar p1 instead
p2 Test3(): NIL // NOTE: FP destroys the memvar p2 instead
p1 Test2(): p1 Test2()
p2 Test2(): p2 Test2()
p1 Start(): p1 Test2()
p2 Start(): p2 Test2()
The memvar.xh RELEASE command creates wrong params e.g. ( "gc1,gc2") instead of ( "gc1" , "gc2" ) which results in a runtime error.