> Some more testing... > With this code: > > With tmp > .y = 0 > tmp = funcx() > With tmp ' Extra with instruction. > Debug .y > Debug tmp.y > End With > End With > > Or with this: > > With tmp > .y = 0 > funcx2(tmp) ' By reference (unfortunately this solution doesn't fit > to my code). > Debug .y > Debug tmp.y > End With > > Public Sub funcx2(test as Class1) > test.y = 1 > End > > Result is what is expected! > > I tried to look at the gambas source code to figure out what is > wrong... beats me up. > But maybe the problem is in how archiver or interpreter handles "tmp = > ...". Extra "with" instruction is workaround, but it's little troublesome > to find where it is needed. > And when "tmp = funcx()" is in "if then else" structure, it is very > troublesome! Maybe I need temporarily to get rid of "with" instructions! > But I hope it is easy to fix! > > Regards, > Jussi > > On Thu, Apr 16, 2009 at 16:17, Jussi Lahtinen <jussi.lahti...@gmail.com> wrote: > > Hi! > > Confirmed on Gambas2 and Gambas3. > > > > Code: > > > > Dim tmp As New Class1 > > > > With tmp > > .y = 0 > > tmp = funcx() > > Debug .y > > Debug tmp.y > > End With > > > > > > Public Function funcx() As Class1 > > Dim test As New Class1 > > > > test.y = 1 > > > > Return test > > End > > > > > > Output of debug is; > > 0 > > 1 > > > > I think .y and tmp.y should be same! > > > > Regards, > > Jussi >
WITH is actually managed at runtime, not at compile time. I mean: WITH var .x = ... .y = ... END WITH is equivalent to: tmp = var tmp.x = ... tmp.y = ... and not to: var.x = ... var.y = ... So, by changing the value of tmp inside the WITH instruction, you are not changing the object WITH works on! Regards, -- Benoît ------------------------------------------------------------------------------ Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user