Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 540
Dan Avatar asked Feb 26 '16 06:02

Dan


People also ask

What is Smalltalk?

Introduction to Smalltalk. Smalltalk is a general purpose object oriented programming language which means that there are no primitives and control structures like a procedural language and in this only objects are communicated by the sending of messages and has its applications in almost every industries and every possible domains. It was ...

How do I get input/output in Smalltalk?

When used with a GUI, Input/Output of Smalltalk is usually done through the Transcript or specialized Workspace windows. Under the Windows operating system, the "stx.exe" program has no console and therefore no interactive input/output. Data written to the output streams will be found in the log file (in the user-specific temp directory).

How to escape from a string in Smalltalk?

The Smalltalk standard does not define any special escapes or other mechanisms to represent unprintable characters (such as <cr>, <tab> or <backspace>) in a string. This is certainly a major missing feature and something that ought to be added in a future Smalltalk standard.

Why is Smalltalk so difficult for non-programmers?

Smalltalk was originally designed to be easily readable by both programmers AND non-programmers. Humor says, that this is one reason why some programmers do not like Smalltalk syntax: they fear to loose their "guru" aura if others understand their code ;-) . sends "negated" to the number 1, which gives us a -1 (minus one) as result.


1 Answers

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.

like image 73
Uko Avatar answered Oct 12 '22 04:10

Uko