>>
APLDN Home

>>
Events

>>
Trainings

>>
APL Books

>>
APLDN Links

>>
Discussion Groups

>>
Downloads

>>
Articles

>>
Library

>>
Learning Tools

>>
APLDN User IO

>>
APL2000.com




Bug Reports

Author Thread: Localization of []WSELF
brent.hildebrand
Localization of []WSELF
Posted: Saturday, January 22, 2005 12:32 PM (EST)

I present the following code sample:

 

    ’ Form rarg;Œwself;A
[1]   :select rarg
[2]   :case 'Create'
[3]       'fm' Œwi 'Create' 'Form' ('size' 10 20)
[4]       'fm.bn' Œwi 'Create' 'Button' ('onClick' "Form'Click'")('style' 1)
[5]       'fm' Œwi 'Show'
[6]   :case 'Click'
[7]       'Œwself' Œwself
[8]       'form' (Œwi ':self')
[9]       'fm' Œwi 'Delete'
[10]  ©    Œwi ':Delete'
[11]  :end
    ’

 

Execute:  

Form 'Create'

 

Now click on the Button fires the onClick handler calling:  Form 'Click'

 

With []WSELF localized, you get the error:

ŒWI OBJECT ERROR: Object "fm" not found
>[???DELETED???;Click] Form'Click'
                       ^

 

This is true for either of the following lines

[9]       'fm' Œwi 'Delete'
[10]  ©    Œwi ':Delete'

 

When the onClick code is called,  []WSELF is defined as shown in the session manager.  The output looks like this:

 Œwself fm.bn
 form fm
ŒWI OBJECT ERROR: Object "fm" not found
>[???DELETED???;Click] Form'Click'

 

questions:

Why does []wself have a value when it is localized?

If []wself has a value, why does  []wi ':Delete'   fail?

More interestingly, why does 'fm' []wi 'Delete' fail if []wself is localized?

 

 


Comments:

Author Thread:
brent.hildebrand
Localization of []WSELF
Posted: Saturday, January 22, 2005 12:38 PM (EST)
I failed to say, if []wself is not localized, no errors occur.

     

Rex.Swain
Localization of []WSELF
Posted: Saturday, January 22, 2005 2:42 PM (EST)

I have struggled with this in the past too, but I think I now understand it. 

 

When the button is clicked, the system (1) sets wself to the button and then (2) executes the handler.  Since the handler localizes wself, when the handler is finished, the system wants to restore wself to the value when it started (fm.bn), but the Form no longer exists, and thus the error.  So it's step (1) that's the key.

 

I have resorted to using

 

Œwi 'Defer' "'fm' Œwi 'Delete'"

 

in cases like this, though I am not very comfortable with it.

     

brent.hildebrand
Localization of []WSELF
Posted: Saturday, January 22, 2005 8:43 PM (EST)

Thanks Rex.  I also used Defer to get around this in a current program where I had this problem.  But to show that what you have observed correct, I changed the onClick as shown below.  If the handler is not dependant on []wself,  setting []wself before calling the handler where []wself is localized, prevents the error message.  Line [4] sets []wself, then calls the function.

 

 

    ’ Form rarg;Œwself;A
[1]   :select rarg
[2]   :case 'Create'
[3]       'fm' Œwi 'Create' 'Form' ('size' 10 20)
[4]       'fm.bn' Œwi 'Create' 'Button' ('onClick' "Œwself„'' ª Form'Click'")('style' 1)
[5]       'fm' Œwi 'Show'
[6]   :case 'Click'
[7]       'fm' Œwi 'Delete'
[8]   :end
    ’

     

j.merrill
Localization of []WSELF
Posted: Saturday, January 22, 2005 9:59 PM (EST)
I find myself in awe that this problem, noted (I'm sure) before v3.6 was released (and probably before 3.0), remains unfixed. (My description of the bug is that the system signals an error, but should instead set #WSELF to '', if it cannot re-set #WSELF to the previous value during unlocalization because the object that had been #WSELF no longer exists.) What do you suppose happens to bug reports that they can disappear for 5 or 6 releases? (Maybe if there were a public list of known bugs, with some kind of status, we could at least make sure that our 3-year-old ones were still on the list.)

     

brent.hildebrand
Localization of []WSELF
Posted: Saturday, January 22, 2005 10:14 PM (EST)
Is it a bug? Or a misunderstanding of how the system works? I now see that the system is trying to set []WSELF back after the function call, but the original object is now gone. It sure felt weird to me, but with Rex's explanation, and demonstrating that indeed the error is prevented by changing []WSELF before it become localized, I'm satisfied that the system is working OK. It feels weird that the error points to a line in the function, but I suspect that the error is happening as the function is terminated and []WSELF is being set back to its pre-function call, but the object is now <<<DELETED>>>. I was just misunderstanding what was happening.

     

j.merrill
Localization of []WSELF
Posted: Sunday, January 23, 2005 8:18 PM (EST)
Rex correctly explained what was going on; it's not the most intuitively obvious situation. What doesn't make any sense -- so I call it a bug -- is that the system has not been modified to be "forgiving" in this situation. It is hard to understand how a programmer could be relying on an error occurring in this situation, and if it did not (because the system set #WSELF to '') his program would malfunction. No one from APL2000 has ever suggested that the "design team" decided that making the system set #WSELF to '' when it can't restore the value of #WSELF during unlocalization, rather than signalling an error, would be "wrong" -- but the system remains unchanged, version after version after version. (It's like the problem that you can't have more than one copy of APL registered for COM at the same time. For how many more versions will that remain true? I hate to bitch, but...)

     

Support
Localization of []WSELF
Posted: Monday, January 24, 2005 5:53 PM (EST)

We agree that this problem has persisted long enough and will therefore take a serious look at resolving this issue once and for all.

As to the issue with the limitation on the number of APL COM registrations, this matter was resolved in version 5.2 with the introduction of the custom APL+Win ActiveX server (APLWCO.DLL).  APL2000 will provide at no charge a custom DLL to customers with a Tier 1, 2 or 3 APLDN subscription.  For others, the charge is $250 (US) per DLL with free updates available with incremental updates to the interpreter.

APL2000 Support

     

davin.church
Localization of []WSELF
Posted: Wednesday, January 26, 2005 1:47 PM (EST)

And to answer your remaining question:

"Why does []wself have a value when it is localized?"

 

It's something called pass-through localization.  Most []-names can't reasonably be a value error, so they're initialized upon localization with their global value.  This can actually be quite handy in certain situations.

     

brent.hildebrand
Localization of []WSELF
Posted: Wednesday, January 26, 2005 3:38 PM (EST)

Of course, variables such as []IO and []CT need to have pass through values.  My problem was understanding what was happening.  If I explicitly assigned []WSELF to a non-existent value, I would get the []WI OBJECT ERROR.  By localizing []WSELF, I was in effect setting its value when the function terminated.  So it is not a bug, just my misunderstanding.

 

An interesting observation: 

 

If you query []SI before deleting the Form,  the "???DELETED???" changes to "fm.bn".  The error message looks funny; the object causing the Click event does not exist. 

 

    ’ Form rarg;Œwself
[1]   :select rarg
[2]   :case 'Create'
[3]       'fm' Œwi 'Create' 'Form' ('size' 10 20)
[4]       'fm' Œwi '‘tic' 123
[5]       'fm.bn' Œwi 'Create' 'Button' ('onClick' "Form'Click'")('style' 1)
[6]   :case 'Click'
[7]       si„Œsi
[8]       Œwi ':Delete'
[9]   :end
    ’
      Form 'Create'
fm
fm.bn
ŒWI OBJECT ERROR: Object "fm" not found
>[fm.bn;Click] Form'Click'

     



APL2000 Official Web Site

Most good judgment comes from experience. Most experience comes from bad judgment.
--- Anonymous

APLDN Home   |    |  Events   |  Trainings   |  APL Books   |  APLDN Links   |    |  Discussion Groups   |    |  Downloads   |  Articles   |  Library   |  Learning Tools   |  APLDN User IO   |  APL2000.com   |