What are the conceptual concepts of Smalltalk?

I used pragmas in Pharo Smalltalk and have an idea of ​​how they work, and I saw examples of what they use in Pharo.

My questions:

  • conceptually pragmas,
  • to which design are they compared in other languages,
  • When should I introduce pragma?

I already found an interesting article about their story: The history of VW Pragmas .

+8
smalltalk squeak pharo visualworks
source share
1 answer

You should think of it as annotations related to CompiledMethod, or if you want as additional properties.

Then, thanks to reflection, some tools can execute other compiled methods, collect those with certain annotations (properties) and apply some special processing, for example, create a menu, preference list or other user interface, calling each class marked as #initializer, or which some mechanism can go on foot until the method is marked as #exceptionHandler ...

There are many possibilities for you to come up with your own meta property ...

EDIT

For the second point, I do not know, it should be a language that can enumerate methods and can attach properties to them.

The third paragraph is also difficult to answer. In practice, I would say that you would use some existing annotations, but very rarely create a new one, unless you are trying to create a new structure for exception handling or a new structure for the graphical interface (you want to register some known events or some handlers .. .). The main use that I would like to see is extension, compilation of an application with unrelated parts, as the main menu. This seems like a relatively unobtrusive way to introduce DECLARATIVE hooks - compared to a very intrusive way to override the famous TheWorld β†’ mainMenu method. It is also a bit easier to register / unregister IMPERATIVELY via traditional message sending when initializing / unloading a class. Magic, on the other hand, is a bit more hidden.

+12
source share

All Articles