lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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