[new to smalltalk] confusing problem: BlockContext >> cannot return

Herbert König herbertkoenig at gmx.net
Wed Nov 24 16:52:42 UTC 2004


Hello together,

I planned to come here with a question if something I did is
acceptable smalltalk (or Squeak) style but as it still doesn't work I
have to come with a bit of code first:

I simplified the problem so it can be copied into a workspace.

"-----Start Workspace"

"This example string is to be converted into an object"
str := 'G      0.000     38.199    1    2    68150.071    97542.712'.

"As several types of strings have to be converted into different
objects I feed them into a kind of method dictionary: to avoid a
procedural case statement"

dict := Dictionary new.
dict   add: 'G' -> ([ :aLine | ^ Random new.]);
       "add: 'G' -> ([ :aLine | ^ ProjektAchsenReader myLineToLine:
                                aLine.]);"
       add: 'B' -> ([ :aLine | ^ ProjektAchsenReader myLineToArc: aLine.]);
       add: 'K' -> ([ :aLine | ^ ProjektAchsenReader myLineToKlotho: aLine.]).


"Printing the following to test the method used in the dictionary works as
expected, so any class method returning a value is usable, i used
Random"

ProjektAchsenReader myLineToLine: str  " results in: an AchselementGerade"
       

"Trying this gives me a stack walkback and a headche :-)"
(dict at: 'G') value: str.

"The intention was to return an AchselementGerade"

"-----End workspace"

The stack walkback:
"BlockContext>>cannotReturn:"
"[] in UndefinedObject>>Doit"

Though "The receiver tried to return result to a method context that
no longer exists." is clear enough in plain english I don't know what
to make of it or how to get rid of it.

I'm sure I missed something fundamental, so please give me a clue!


Best regards,

Herbert                          mailto:herbertkoenig at gmx.net




More information about the Squeak-dev mailing list