[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [Proposal] Allow yields through string.gsub
- From: Sean Conner <sean@...>
- Date: Wed, 6 Apr 2016 13:39:30 -0400
It was thus said that the Great Soni L. once stated:
> With the recent changes to string.gmatch and the whole pattern matching
> code, it seems like now it's much easier to allow yields through
> string.gsub. May Lua users have yieldable string.gsub?
>
> Goals of this proposal:
> 1. Let coroutines be used for fast dynamic substitution, something we
> currently can't do.
I'm not sure what you mean by this.
require "org.conman.math".randomseed()
function s()
return string.char(math.random(65,90))
end
x = "Sean Conner"
y = x:gsub(".",s)
print(y)
print(y)
print(y)
outputs:
DEGRBZSMIUK
VRAOMQWDXJK
SLKVQGMTFOC
> Another option would be to just add buffers, which would, in theory, let
> you reimplement most of the standard libraries in pure Lua, with
> performance and memory characteristics closer to the C functions.
No one is stopping you from doing just that and reporting back here with
how it performs.
-spc