I have the following code:
function p (str)
Response.Write VBLF & str
end function
function nop: end function
class Test1
private sub class_initialize
p "Test1 Start"
end sub
private sub class_terminate
p "Test1 End"
end sub
end class
class Test2
private sub class_initialize
p " Test2 Start"
end sub
private sub class_terminate
p " Test2 End"
end sub
end class
When I run:
with new Test1
with new Test2
end with
end with
I expect the output:
Test1 Start
Test2 Start
Test2 End
Test1 End
But I get:
Test1 Start
Test2 Start
Test1 End
Test2 End
I do, however, get what I expected if I run either of the following:
with new Test1
with new Test2
nop
end with
end with
with new Test1
with new Test2
end with
nop
end with
But not the following:
with new Test1
nop
with new Test2
end with
end with
VBScript has a fairly strong guarantee about GC'ing objects right away, and I'm using (abusing?) this guarantee for a variety of purposes in my applications. Without the nop
, why is it collecting Test1
and Test2
in the "wrong" order?