odd bug in Squeak 4.3, also in Pharo 1.3?...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

odd bug in Squeak 4.3, also in Pharo 1.3?...

LawsonEnglish
I was creating a new video tutorial to show how to find all comments in
all classes but I'm getting errors in both Squeak 4.3 and Pharo 1.3.

In Squeak 4.3, the  error is: Key not found: Comment

In Pharo 1.3, the error is: Improper store into indexable object.


the code is:

myNav := SystemNavigation default.

(myNav allMethodsWithSourceString: '"' matchCase: false) do:
      [:each| Transcript show: each asString, ' => ', ( each  
actualClass commentsIn: each sourceString);cr ]


In Pharo, the error shows up after the Transcript output:

UndefinedObject>>DoIt (myNav is Undeclared)

In Squeak the error shows up each time after the Transcript output:

[...]
AbstractSound class updateScorePlayers => an OrderedCollection('Force
all ScorePlayers to update their instrument list from the sound library.
This may done after loading, unloading, or replacing a sound to make all
ScorePlayers feel the change.')

UndefinedObject>>DoIt (myNav is Undeclared)
UndefinedObject>>DoIt (myNav is Undeclared)





Help? Error shows up in Squeak 4.3 image running both in the all-in-one
distribution, and running on Cog VM.

In Pharo 1.3 using Cog VM.

Mac OS X 10.6.8.

Thanks,

  Lawson





Reply | Threaded
Open this post in threaded view
|

Re: odd bug in Squeak 4.3, also in Pharo 1.3?...

Nicolas Cellier
Le 2 mars 2012 04:21, Lawson English <[hidden email]> a écrit :

> I was creating a new video tutorial to show how to find all comments in all
> classes but I'm getting errors in both Squeak 4.3 and Pharo 1.3.
>
> In Squeak 4.3, the  error is: Key not found: Comment
>
> In Pharo 1.3, the error is: Improper store into indexable object.
>
>
> the code is:
>
> myNav := SystemNavigation default.
>
> (myNav allMethodsWithSourceString: '"' matchCase: false) do:
>     [:each| Transcript show: each asString, ' => ', ( each  actualClass
> commentsIn: each sourceString);cr ]

Yes, this doesn't work:

'abc' , #( 'de'  'fgh').

But you could simply do this:

myNav := SystemNavigation default.
(myNav allMethodsWithSourceString: '"' matchCase: false) do:
    [:each| Transcript show: each asString -> ( each  actualClass
commentsIn: each sourceString);cr ]

Nicolas

>
>
> In Pharo, the error shows up after the Transcript output:
>
> UndefinedObject>>DoIt (myNav is Undeclared)
>
> In Squeak the error shows up each time after the Transcript output:
>
> [...]
> AbstractSound class updateScorePlayers => an OrderedCollection('Force all
> ScorePlayers to update their instrument list from the sound library. This
> may done after loading, unloading, or replacing a sound to make all
> ScorePlayers feel the change.')
>
> UndefinedObject>>DoIt (myNav is Undeclared)
> UndefinedObject>>DoIt (myNav is Undeclared)
>
>
>
>
>
> Help? Error shows up in Squeak 4.3 image running both in the all-in-one
> distribution, and running on Cog VM.
>
> In Pharo 1.3 using Cog VM.
>
> Mac OS X 10.6.8.
>
> Thanks,
>
>  Lawson
>
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: odd bug in Squeak 4.3, also in Pharo 1.3?...

LawsonEnglish
On 3/2/12 4:29 AM, Nicolas Cellier wrote:
> myNav := SystemNavigation default.
> (myNav allMethodsWithSourceString: '"' matchCase: false) do:
>      [:each| Transcript show: each asString ->  ( each  actualClass
> commentsIn: each sourceString);cr ]


Now I get the same error in the same place with Pharo 1.3 as I do in
Squeak 4.3 though the error message is different:

MNU: CommentReference>>sourceString.

So my original code mostly works with Squeak 4.3, but doesn't work at
all with Pharo 1.3

Your code has errors in the same place as mine does in Squeak 4.3, but
at least it mostly works in Pharo 1.3 as well as Squeak 4.3.


I'm pretty sure this isn't proper behavior, either way.


Lawson







Reply | Threaded
Open this post in threaded view
|

Re: odd bug in Squeak 4.3, also in Pharo 1.3?...

Nicolas Cellier
Le 2 mars 2012 13:24, Lawson English <[hidden email]> a écrit :

> On 3/2/12 4:29 AM, Nicolas Cellier wrote:
>>
>> myNav := SystemNavigation default.
>> (myNav allMethodsWithSourceString: '"' matchCase: false) do:
>>     [:each| Transcript show: each asString ->  ( each  actualClass
>> commentsIn: each sourceString);cr ]
>
>
>
> Now I get the same error in the same place with Pharo 1.3 as I do in Squeak
> 4.3 though the error message is different:
>

Sure, I should have written Transcript print: ... ; cr; endEntry

Or Transcript show: each asString , ' => ' ,  ( each  actualClass
commentsIn: each sourceString) printString;cr

Nicolas

> MNU: CommentReference>>sourceString.
>
> So my original code mostly works with Squeak 4.3, but doesn't work at all
> with Pharo 1.3
>
> Your code has errors in the same place as mine does in Squeak 4.3, but at
> least it mostly works in Pharo 1.3 as well as Squeak 4.3.
>
>
> I'm pretty sure this isn't proper behavior, either way.
>
>
> Lawson
>
>
>
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: odd bug in Squeak 4.3, also in Pharo 1.3?...

LawsonEnglish
On 3/2/12 5:55 AM, Nicolas Cellier wrote:
> Transcript print: ... ; cr; endEntry
myNav := SystemNavigation default.
(myNav allMethodsWithSourceString: '"' matchCase: false) do:
     [:each| Transcript show: each asString -> ( each  actualClass
commentsIn: each sourceString);cr;endEntry ]

Still generates the error MNU: ComentReference>>sourceString

On Pharo 1.3

Still generates the error: MNU: Key not found: Comment

On Squeak 4.3



AFTER many hundreds of lines of valid output.

In the same place as before in both images with 2 different VMs.



Are you testing the code you are writing and not seeing the error?

L

Reply | Threaded
Open this post in threaded view
|

Re: odd bug in Squeak 4.3, also in Pharo 1.3?...

Nicolas Cellier
Ah sorry, I missed one part of your report (and no, I did not have an
image handy).

My answer was more for Pharo since you cannot concatenate
    'foo' , Object new
You need to use explicitely asString or printString or storeString or...
    'foo' , Object new asString

Then, the #Comment failure sounds wrong indeed.
That's just because allMethodsWithSourceString: also scan class comments...
And this is hackish because:
- the class comment is not a method, so allMethodsWithSourceString: is
quite a surprising behavior-name mismatch
- the least we should do would be to return a ClassCommentReference
rather than a MethodReference if we want to maintain this feature.

Nicolas


Le 2 mars 2012 21:57, Lawson English <[hidden email]> a écrit :

> On 3/2/12 5:55 AM, Nicolas Cellier wrote:
>>
>> Transcript print: ... ; cr; endEntry
>
> myNav := SystemNavigation default.
> (myNav allMethodsWithSourceString: '"' matchCase: false) do:
>    [:each| Transcript show: each asString -> ( each  actualClass
> commentsIn: each sourceString);cr;endEntry ]
>
> Still generates the error MNU: ComentReference>>sourceString
>
> On Pharo 1.3
>
> Still generates the error: MNU: Key not found: Comment
>
> On Squeak 4.3
>
>
>
> AFTER many hundreds of lines of valid output.
>
> In the same place as before in both images with 2 different VMs.
>
>
>
> Are you testing the code you are writing and not seeing the error?
>
> L
>

Reply | Threaded
Open this post in threaded view
|

Re: odd bug in Squeak 4.3, also in Pharo 1.3?...

Bob Arning-2
In reply to this post by LawsonEnglish
If you change

MethodReference>>sourceString so that it looks like this:

sourceString

    self methodSymbol = #Comment ifTrue: [^self actualClass comment].
    ^ (self actualClass sourceCodeAt: self methodSymbol) asString

your code will run in Squeak 4.2 and presumably 4.3.

Cheers,
Bob

On 3/2/12 3:57 PM, Lawson English wrote:
On 3/2/12 5:55 AM, Nicolas Cellier wrote:
Transcript print: ... ; cr; endEntry
myNav := SystemNavigation default.
(myNav allMethodsWithSourceString: '"' matchCase: false) do:
    [:each| Transcript show: each asString -> ( each  actualClass
commentsIn: each sourceString);cr;endEntry ]

Still generates the error MNU: ComentReference>>sourceString

On Pharo 1.3

Still generates the error: MNU: Key not found: Comment

On Squeak 4.3



AFTER many hundreds of lines of valid output.

In the same place as before in both images with 2 different VMs.



Are you testing the code you are writing and not seeing the error?

L




Reply | Threaded
Open this post in threaded view
|

Re: odd bug in Squeak 4.3, also in Pharo 1.3?...

LawsonEnglish
Is that a bug fix, or a workaround, I wonder?

Regardless, I'll  redo the video but add the caveat that due to an existing issue, one needs to add an extra line of code to skip printing out methods whose symbol is #Comment.

L.

On 3/2/12 3:57 PM, Bob Arning wrote:
If you change

MethodReference>>sourceString so that it looks like this:

sourceString

    self methodSymbol = #Comment ifTrue: [^self actualClass comment].
    ^ (self actualClass sourceCodeAt: self methodSymbol) asString

your code will run in Squeak 4.2 and presumably 4.3.

Cheers,
Bob

On 3/2/12 3:57 PM, Lawson English wrote:
On 3/2/12 5:55 AM, Nicolas Cellier wrote:
Transcript print: ... ; cr; endEntry
myNav := SystemNavigation default.
(myNav allMethodsWithSourceString: '"' matchCase: false) do:
    [:each| Transcript show: each asString -> ( each  actualClass
commentsIn: each sourceString);cr;endEntry ]

Still generates the error MNU: ComentReference>>sourceString

On Pharo 1.3

Still generates the error: MNU: Key not found: Comment

On Squeak 4.3



AFTER many hundreds of lines of valid output.

In the same place as before in both images with 2 different VMs.



Are you testing the code you are writing and not seeing the error?

L





    



Reply | Threaded
Open this post in threaded view
|

Re: odd bug in Squeak 4.3, also in Pharo 1.3?...

LawsonEnglish
In reply to this post by Nicolas Cellier
This code runs with no errors on both images:

myNav := SystemNavigation default.
(myNav allMethodsWithSourceString: '"' matchCase: false) do:
     [:each| each methodSymbol = #Comment
         ifTrue: ["handle true case later"]
         ifFalse: [Transcript show: each asString -> ( each  actualClass
commentsIn: each sourceString);cr ]]

but this line only works in Squeak 4.3: ifFalse: [Transcript show: each
asString, '=>', ( each  actualClass commentsIn: each sourceString);cr ]]


Interesting divergence in the code there.


Lawson


On 3/2/12 3:52 PM, Nicolas Cellier wrote:

> Ah sorry, I missed one part of your report (and no, I did not have an
> image handy).
>
> My answer was more for Pharo since you cannot concatenate
>      'foo' , Object new
> You need to use explicitely asString or printString or storeString or...
>      'foo' , Object new asString
>
> Then, the #Comment failure sounds wrong indeed.
> That's just because allMethodsWithSourceString: also scan class comments...
> And this is hackish because:
> - the class comment is not a method, so allMethodsWithSourceString: is
> quite a surprising behavior-name mismatch
> - the least we should do would be to return a ClassCommentReference
> rather than a MethodReference if we want to maintain this feature.
>
> Nicolas
>
>
> Le 2 mars 2012 21:57, Lawson English<[hidden email]>  a écrit :
>> On 3/2/12 5:55 AM, Nicolas Cellier wrote:
>>> Transcript print: ... ; cr; endEntry
>> myNav := SystemNavigation default.
>> (myNav allMethodsWithSourceString: '"' matchCase: false) do:
>>     [:each| Transcript show: each asString ->  ( each  actualClass
>> commentsIn: each sourceString);cr;endEntry ]
>>
>> Still generates the error MNU: ComentReference>>sourceString
>>
>> On Pharo 1.3
>>
>> Still generates the error: MNU: Key not found: Comment
>>
>> On Squeak 4.3
>>
>>
>>
>> AFTER many hundreds of lines of valid output.
>>
>> In the same place as before in both images with 2 different VMs.
>>
>>
>>
>> Are you testing the code you are writing and not seeing the error?
>>
>> L
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: odd bug in Squeak 4.3, also in Pharo 1.3?...

Nicolas Cellier
In reply to this post by LawsonEnglish
Le 3 mars 2012 00:04, Lawson English <[hidden email]> a écrit :
> Is that a bug fix, or a workaround, I wonder?
>

It's the shortest hack to make your sentence work.
Certainly not a long term scaling solution, because we would have to
spread some more ifTrue: here and there
- in both MethodReference
- and its users.
The former is a way to accomplish poor man polymorphism
The later is a way to have complex code which can't abstract and
delegate, but instead has to be omniscient
See for example MessageSet>>contents:notifying:

I'd say Squeak can tolerate such hack (it's just one more in the image).
But Pharo wouldn't. MethodReference has already been cleaned up in 1.4 ;)

Nicolas

> Regardless, I'll  redo the video but add the caveat that due to an existing
> issue, one needs to add an extra line of code to skip printing out methods
> whose symbol is #Comment.
>
> L.
>
>
> On 3/2/12 3:57 PM, Bob Arning wrote:
>
> If you change
>
> MethodReference>>sourceString so that it looks like this:
>
> sourceString
>
>     self methodSymbol = #Comment ifTrue: [^self actualClass comment].
>     ^ (self actualClass sourceCodeAt: self methodSymbol) asString
>
> your code will run in Squeak 4.2 and presumably 4.3.
>
> Cheers,
> Bob
>
> On 3/2/12 3:57 PM, Lawson English wrote:
>
> On 3/2/12 5:55 AM, Nicolas Cellier wrote:
>
> Transcript print: ... ; cr; endEntry
>
> myNav := SystemNavigation default.
> (myNav allMethodsWithSourceString: '"' matchCase: false) do:
>     [:each| Transcript show: each asString -> ( each  actualClass
> commentsIn: each sourceString);cr;endEntry ]
>
> Still generates the error MNU: ComentReference>>sourceString
>
> On Pharo 1.3
>
> Still generates the error: MNU: Key not found: Comment
>
> On Squeak 4.3
>
>
>
> AFTER many hundreds of lines of valid output.
>
> In the same place as before in both images with 2 different VMs.
>
>
>
> Are you testing the code you are writing and not seeing the error?
>
> L
>
>
>
>
>
>
>
>