Suggestion of a latent expression for workspace closure

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
Post Reply
michaelk
Posts: 34
Joined: Wed Feb 10, 2010 8:38 am

Suggestion of a latent expression for workspace closure

Post by michaelk »

Much as latent expressions now are executed when a workspace is opened, I think it would be useful also to have latent-like expressions that are executed when a workspace is closed. One application of such a latent expression could be to expunge any printer object that happened to remain open when the workspace was closed.

Would anyone else find this proposed extension to Dyalog useful?
User avatar
Dick Bowman
Posts: 235
Joined: Thu Jun 18, 2009 4:55 pm
Contact:

Re: Suggestion of a latent expression for workspace closure

Post by Dick Bowman »

I think that this could/would be properly done by your application code. The point of ⎕LX being to force some application code to run when the interpreter has just started and has nothing to do - ⎕LX gives it that something. But once you've started, then you're in control.

Of course, I write this from a context of domineering applications. There might be a case where your workspace is just sitting there waiting for you to interact with it.

But personally, I don't think I've ever felt the need...
Visit http://apl.dickbowman.com to read more from Dick Bowman
paulmansour
Posts: 431
Joined: Fri Oct 03, 2008 4:14 pm

Re: Suggestion of a latent expression for workspace closure

Post by paulmansour »

Isn't this better accomplished with a simple Off function that does what you want and then does a quadOFf at the end? ? As Dick notes, the reason for quadLX is that you want something to happen automatically. You have to take action as it is to close a session, so why not do Off instead of )Off.
michaelk
Posts: 34
Joined: Wed Feb 10, 2010 8:38 am

Re: Suggestion of a latent expression for workspace closure

Post by michaelk »

But there are numerous ways that a workspace can be closed other than by typing ')OFF'. They include loading another workspace, closing the session window, etc. My proposed latent-expression-at-workspace-closure would be invoked in all such circumstances.
Vince|Dyalog
Posts: 439
Joined: Wed Oct 01, 2008 9:39 am

Re: Suggestion of a latent expression for workspace closure

Post by Vince|Dyalog »

Hi MichaelK,

Just to let you know, we do expunge your GUI objects such as printer objects when you )clear or load another workspace or Exit the interpreter.

JD has said to me that you can achieve some of what you are asking for with classes, event callbacks, and a destructor method.

Here is what I've come up with:

)cs ⎕SE

Start editing a new class:
)ed ○wsdestro

Paste the following into the editor and save it.

Code: Select all

:Class wsdestro

    ∇ closing
      :Implements Destructor
      'm'⎕WC'msgbox' 'Closing...'
      ⎕DQ'm'
     
    ∇
:EndClass


Add the following initialization function call to the WorkspaceLoaded event callback.
)ed ⎕SE.Dyalog.Callbacks.WSLoaded

⎕SE.wsclosingmsg←⎕NEW ⎕SE.wsdestro

Save the session file.

Regards,

Vince
Post Reply