Dan
Dan

Reputation: 1183

Exit program in smalltalk?

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!

Upvotes: 6

Views: 1443

Answers (1)

Uko
Uko

Reputation: 13386

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.

Upvotes: 5

Related Questions