> Hi, I have one begginer question. It is may be simple, but it very baffles me.
>
> I am reading Pharo by Example (great book btw, thanks!). I'm in chapter two where I'm creating Lights Out game. There is this simple code http://pastebin.com/eQregZ35. What baffles me is line 10. I assign "Block of code" to mouseAction variable of LOCell. In this Block, there is "self", that obviously refers to LOGame object in that time. But when is this Block actualy EVALUATED (when I click on Cell), "self" should be reffering to LOCell object, isn't it? If I inspect one LOCell, inspector shows that it has instance variable "mouseAction", which is BlockClosure, that looks like "[self toggleNeighboursOfCellAt: i at: j]". If "LOCell" is the "owner" of this block and also it is the one that evaluates it, shouldn't "self" refer to LOCell object? How BlockClosure desides where "self" actually points?
>
> Thanks for explanation.
Here is a draft of a next chapter on block :)
But I should finish it :)
The message names are greedy, so in your example "5 raisedTo: 6
modulo: 3" will send the #raisedTo:modulo: message to 5 with arguments
6 and 3. If you wanted to send #raisedTo: and then #modulo: you'd have
to use parentheses: "(5 raisedTo: 6) modulo: 3".
frank
Not the longest (in: the longest available), but whole.
Concatenation of all xxx: keyword in the whole statement or
parenthesised expression is used. I doesn't matter if #foo: exists if
statement is 1 foo: 3 bar: 5; it is always #foo:bar:.
Herby
It is common convention for example methods to be presented in text
using '>>' preceded by the class. This is obviously needed to define
the class/method relationship outside the image, but the whole example
cannot be pasted directly into System Browser as the '>>' is not part of
the Smalltalk syntax for defining methods.
For those new to Pharo going through tutorials, copy/pasting the whole
of the presented code eg [1] returns only the error "Nothing more
expected" which is a bit cryptic to noobs who expect to follow the
example verbatim. Once past understanding this, it continues (for me)
to be a minor annoyance to have to select only the text following the '>>'.
I wonder whether it would be beneficial for the compiler to handle
'>>' at the start of a method definition. The System Browser would
then jump to the created method. As well as beneficial to those
experiencing Pharo for the first time, this might be useful as a general
shortcut such that when browsing one class you can define a method for
another class without first having to browse to that class.
cheers, Ben
[1]
BExp>>testBlock: aBlock
| t |
t := nil.
aBlock value
String >> #asDate
^1
The above is not valid, so no conflict in this context.
Stef
I agree, I don't see any conflict. I also like the proposal. Ben, do
you think you could try to implement a prototype? I advise you to
implement it either for OmniBrowser or for Nautilus and see if it
makes sense.
Thanks for the proposal
--
Damien Cassou
http://damiencassou.seasidehosting.st
"Lambdas are relegated to relative obscurity until Java makes them
popular by not having them." James Iry
Cheers,
Doru
"Every thing has its own flow"
>
> Just a passing thought....
> It is common convention for example methods to be presented in text using '>>' preceded by the class. This is obviously needed to define the class/method relationship outside the image, but the whole example cannot be pasted directly into System Browser as the '>>' is not part of the Smalltalk syntax for defining methods.
> For those new to Pharo going through tutorials, copy/pasting the whole of the presented code eg [1] returns only the error "Nothing more expected" which is a bit cryptic to noobs who expect to follow the example verbatim. Once past understanding this, it continues (for me) to be a minor annoyance to have to select only the text following the '>>'.
would be nice!
> I wonder whether it would be beneficial for the compiler to handle '>>' at the start of a method definition. The System Browser would then jump to the created method. As well as beneficial to those experiencing Pharo for the first time, this might be useful as a general shortcut such that when browsing one class you can define a method for another class without first having to browse to that class.
Ideally I would like to have also the support for coral syntax :)
(the other) Ben ;)