Exit program in smalltalk?
Asked Answered
G

1

6

C++ has System.exit(0), VB has End, C# has Application.Exit

How would you exit a program in Smalltalk? I'm using Pharo. Note: I'm not looking to exit Pharo itself, but to just terminate my program during this specific instruction.

I found how to exit Pharo itself but again this isn't what I'm looking for: Smalltalk exit: 0.

Thanks for any help!

Gorey answered 26/2, 2016 at 6:13 Comment(1)
What is a program in the context of Smalltalk? Do you mean an application like a Browser, a Debugger or a Workspace?Disenthrall
A
5

You question actually has two parts. So exiting Pharo itself is the equivalent to System.exit(0). Because a system is running a C++ process, and then it exits, same applies to Pharo.

So continuing this: you may consider launching another pharo image from your current one and terminating the process itself if you want.

What you are really asking is how to exit some part of code being executed in Pharo. And this is a complicated question because you have to also answer where is the boundary between your code and Pharo. I think that it depends on your implementation. Maybe it's enough to close a window, or remove an instance of your class from somewhere.

If you want a more generic approach you can start the execution in a separate pharo process by using [ ] fork and then stop it by either sending it suspend or terminate (you can get the active process with Processor activeProcess). Alternatively you can do thisContext terminate.

Aviator answered 26/2, 2016 at 7:23 Comment(1)
And in practice we only use the generic approach for server like processes.Katherinkatherina

© 2022 - 2024 — McMap. All rights reserved.