This makes sense now.
Thanks for clarifying the issue Esteban. Much appreciated :)



From: [email protected] 
[mailto:[email protected]] On Behalf Of Esteban 
Lorenzano
Sent: Saturday, March 23, 2013 3:23 PM
To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] Method Calling Inside Nested Blocks

yes, you need to end the statement (with a dot), then add the receiver.

btw... the compiler will not complain if you do not put a dot, but your code 
will not work, because the compiler will interpret that you are sending the 
message AfterDOCTYPENameState to the object "false"... and then when you reach 
that place in your execution, you will have a doesNotUnderstand error :)

Esteban

On Mar 23, 2013, at 2:14 PM, "Mohammad Al Houssami (Alumni)" 
<[email protected]<mailto:[email protected]>> wrote:


Probably because I am not using dots except at the end of blocks which I think 
is wrong.
This is a sample of what I had earlier:
currentCharacter = CHARACTERTABULATION  ifTrue: [anythingElseBoolean:= false
                AfterDOCTYPENameState value: currentCharacter ].
There should be a dot after false right ? Once I add the dot I get a complain.



From: 
[email protected]<mailto:[email protected]>
 
[mailto:[email protected]<mailto:[email protected]>]
 On Behalf Of Esteban Lorenzano
Sent: Saturday, March 23, 2013 3:09 PM
To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] Method Calling Inside Nested Blocks

if it is a method, it needs the receiver, in this case "self" (remember, any 
call in smalltalk is: receiver+message).
If for some weird reason you did not need it before (like some chained call 
effect), that was just by chance... you just were lucky before :)

Esteban

On Mar 23, 2013, at 1:58 PM, "Mohammad Al Houssami (Alumni)" 
<[email protected]<mailto:[email protected]>> wrote:



So the method declaration should be self afterDOCTYPEPublicKeywordState: 
currentCharacter. ?

But I have been doing the same for quite some time and I wasn't getting any 
complains. This is the first time and the only thing that changed is that I 
have two blocks in this case. As I said earlier if I move the method call 
outside the block it works with no complains :)

I'll change the names of all my methods to camel case. Thanks for that


From: 
[email protected]<mailto:[email protected]>
 
[mailto:[email protected]<mailto:[email protected]>]
 On Behalf Of Esteban Lorenzano
Sent: Saturday, March 23, 2013 2:52 PM
To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] Method Calling Inside Nested Blocks


On Mar 23, 2013, at 12:31 PM, "Mohammad Al Houssami (Alumni)" 
<[email protected]<mailto:[email protected]>> wrote:




Hello everyone

I was trying to save my method which has the below piece of code

anythingElseBoolean = false ifFalse: [
                doctypeString := reader next: 6
                doctypeString asLowercase =  'public'     ifTrue: [
                                AfterDOCTYPEPublicKeywordState value: 
currentCharacter
                                ]

I get a complain that the AfterDOCTYPEPublicKeywordState is unknown even though 
I have a method with this name.

AfterDOCTYPEPublicKeywordState is a METHOD????
then, you are missing some points:

1) it does not conforms conventions (it should start with lowercase)
2) you need a self call

so, it would be like this:

self afterDOCTYPEPublicKeywordState value: currentCharacter.

but that is also wrong from a design point of view (anti demeters law). So, you 
better create a (perhaps private) method who does the assignment. And then you 
have something like this:

self afterDOCTYPEPublicKeywordState: currentCharacter.

Esteban




If I move the method call outside outside the ifTrue block to the ifFalse block 
it doesn't complain.

Is the problem because of nested blocks ? If that's the case then what would be 
a good work around ?





Thanks
Mohammad

Reply via email to