Tweaking string.gsub so it's yieldable

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Tweaking string.gsub so it's yieldable

Soni "They/Them" L.
How can I tweak string.gsub so it's yieldable?

More specifically I want my tweaked Lua to support this:
c = coroutine.create(function() return string.gsub("test", ".", coroutine.yield) end)
for i = 1, 4 do
	print(coroutine.resume(c))
end
-- 
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.
Reply | Threaded
Open this post in threaded view
|

Re: Tweaking string.gsub so it's yieldable

Patrick Donnelly
On Tue, Dec 23, 2014 at 3:03 PM, Soni L. <[hidden email]> wrote:
> How can I tweak string.gsub so it's yieldable?
>
> More specifically I want my tweaked Lua to support this:
>
> c = coroutine.create(function() return string.gsub("test", ".",
> coroutine.yield) end)
> for i = 1, 4 do
> print(coroutine.resume(c))
> end

What's wrong with string.gmatch?

--
Patrick Donnelly