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

Jakob Reschke forums.jakob at resfarm.de
Wed Aug 21 22:25:50 UTC 2019


(including the list in addresses again)

Am Mi., 21. Aug. 2019 um 23:53 Uhr schrieb gettimothy <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/35b2c530/attachment.html>


More information about the Squeak-dev mailing list