[Pharo-users] Question when reading UPBE

Dimitris Chloupis kilon.alios at gmail.com
Tue Oct 20 02:47:59 EDT 2015

Let me make this clear, I dont believe in stupid questions. Your first
language , like me, is not English and so you have harder time to
understand documentation. Coding nowdays is as much about learning English
than is about learning how to code since its by far the most popular
language that coders around the world use to communicate.

So take it step by step and you will be fine.

No next time you dont understand anything you come here and ask question.
Ask a thousand questions, we love questions :)

Do not suffer alone !

Now about your questions yes you understand correctly >> means "belongs
to". Unfortunately there is a confusing part on the browser , the class
button. The class button switches between something called instance side
and class side. However this is confusing for newcomers like I was. What
really happens is that it switches between the class object itself
(instance side) and the metaclass object (class side). Metaclass is
basically the class of a class.

To make it clear if we accept here that a Class is a blueprint / factory
for our instances , a metaclass is a blueprint/factory for a class. The
diffirence if that you can have several instances from the same class but
there is only one metaclass for a class.

This happens for example when you issue the command in the Playground.

LOGame new.

The above command creates an instance object using the class object as a

But you can have one metaclass of a class , and this is why they share the
same name and they appear to be each side of the same coin.

Usually >> refers to the class itself and not the metaclass. No you dont
need to type this as you can see.

The diffirence is that if the method is in the metaclass (class side) you
dont need to create an isntance fo. Lets take the example where
cellsPerSide is a class method

a = LOGame new
a cellsPerSide

we create a variable that hold the instance object created with LOGame
class object and then we send the cellsPerSide message

however what happens if the cellsPerSide is in the metaclass ? then we have

LOGame cellsPerSide

as you can see no need to create instance here since its now a metaclass
method. Usually you need a metaclass method when you dont need to operate
on specific set of data and instance method when you do. Of course a
metaclass method can still have arguments and receive data so this is far
form clear rule.

The real power of metaclass is that they can do metaprogramming, what that
means is that they can shape and change classes from inside your code which
makes them very powerful. You have also metaclass of a metaclass . As a
matter of fact a metaclass is an instance of another metaclass. But you
dont need to worry about this for now, keep it simple.

On Tue, Oct 20, 2015 at 7:21 AM 小橙橙 <zhushuai19890918 at gmail.com> wrote:

> You mean that I  should type them in the pane of the method I want to
> define, am I right?
> then, which one should I type "LOGame>>cellsPerSide" or "cellsPerSide"?
> Maybe this syntax --">>" just indicates that this method should belong to
> this class. but as reader, I don't need to type all, do I ?
> My English is poor and When I reader it a little faster, I will be
> confused. Next time , if I encounter some sentences I don't understand, I
> will read other sentences around them again.
> Thx you all to spare time for my stupid questions :)
> 2015-10-20 2:02 GMT+08:00 Dimitris Chloupis <kilon.alios at gmail.com>:
>> have your read the Pharo Tour chapter ?
>> please read the entire book from start to finish , DO NOT skip chapters
>> this is a complete tutorial on Pharo that depends on previous chapters for
>> continuation of knowledge. If you dont understand previous chapters you
>> wont understand this.
>> Your question is explained at Page 16, chapter: A quick tour of Pharo
>> On Mon, Oct 19, 2015 at 6:50 PM 小橙橙 <zhushuai19890918 at gmail.com> wrote:
>>> Hi,
>>>     I'm a newcomer in Pharo and start to learn how to use Pharo.
>>>     In page 42 of UPBE(Vesion:2015-10-17 ), I don't know where I write
>>> the constant methods and UPBE didn't tell me in which pane to type them.
>>>     Could you tell me ?
>>> Andy Zhu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20151020/0888f956/attachment.html>

More information about the Pharo-users mailing list