0

In Smalltalk are there functions or procedures? Is it possible to send a function or procedure to a subprogram?

And in another question: Can I send multi-dimensional arrays to a subprogram?

3 Answers 3

4

I think I didn't understand your question. In Smalltalk there is nothing like functions, procedures or subprograms. It is all about objects and messages. A Messages implementation is called a Method.

Methods are reified as instances of CompiledMethod class. Hence, since they are objects, they can be passes arround by parameter, be stored in variables, etc.

Multi-dimensional array?? You have the class Matrix. Is that what you want?

I would recommend you to read the first chapters of Pharo By Example book. It will help you to get an introduction.

http://pharobyexample.org/

0
1

In Smalltalk, blocks are similar to anonymous functions. You can pass blocks as an argument in a message, just like you pass any other object as an argument.

But you should definitely read the book suggested by Mariano to learn the basic language concepts.

1

Yes, please read the book, because your questions showing almost total absence of smalltalk knowledge. In smalltalk there is only few concepts: objects and messages. A methods are implementing behavior for specific messages.

A special object - closure is one that you want. You can pass a closure as argument in some message (or store it in some object) and evaluate it at any point.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.