[squeak-dev] Problem storing Lua code in dynamically created class side method.

Marcel Taeumel marcel.taeumel at hpi.de
Thu Aug 22 06:08:31 UTC 2019

Hi, there.

#printString on String does the trick:

methodTemplateLua := 'lua ^ {1}'.
methodSourceLua := methodTemplateLua format: { lua printString }.

Am 22.08.2019 00:26:15 schrieb Jakob Reschke <forums.jakob at resfarm.de>:
(including the list in addresses again)

Am Mi., 21. Aug. 2019 um 23:53 Uhr schrieb gettimothy <gettimothy at zoho.com [mailto:gettimothy at zoho.com]>:

"1. Can't you just replace each ' in your Lua text by '' (two single quotes) before compiling the Smalltalk method string? It escapes the single quotes in the string."

How?  I tried wrapping it with String Concatenation and it failed to compile.

", oldtext, ".

    methodTemplateLua := 'lua ^ ''{1}'''.
    methodSourceLua := methodTemplateLua format:
       {lua copyReplaceTokens: '''' "four single quotes" with: '''''' "six single quotes"}.

Or for more comfortable reading:

    lua copyReplaceTokens: (String with: $') with: (String with: $' with: $')

Still, I would avoid tinkering with the code and go with the (class) instance variable approach if possible.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190822/60a2b69c/attachment.html>

More information about the Squeak-dev mailing list