At 12:41 PM 4/28/98 +0900, Chun, Sung Jin wrote:
I want to make string like in ObjC; [ str concatSTR: 'Hello' ]; But in Smalltalk I cannot find it. And also I want printf like feature in error: like this; self error: 'Class %s', [ self name ] Can anyone teach me how I can do this ?
We extended VisualWorks some time back to handle this kind of string "macro expansion", including arguments, by adding an #expandMacrosWith:* family of messages and creating a class (StringParameterSubstitution) to do the work.
For example: 'hello, <1s>' expandMacrosWith: 'Chun' returns 'hello, Chun' or '<1?Guten Tag:Hello>, <2s>' expandMacrosWith: isGerman with: 'Chun' returns 'Guten Tag, Chun' or 'Hello, Chun', depending on the value of the boolean isGerman.
As you suggest, this is used a lot in error handlers and other places, especially in the face of internationalization.
I don't think it's a huge project to create this functionality in Squeak, and while you can't steal the VW code, I think we'd benefit from having compatible syntax, so I'd encourage you or some other Squeaker to check out the VW description.
glenn
squeak-dev@lists.squeakfoundation.org