sending function/procedure and multi-dimensional array to subprogram in smalltalk
In Smalltalk are there functions or procedures? Is it possible to send a function or proc开发者_如何学Goedure to a subprogram?
And in another question: Can I send multi-dimensional arrays to a subprogram?
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/
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.
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.
精彩评论