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 Thijs Schreijer once stated:
> my 2cts: stay away from YAML. Especially if users are supposed to edit it
> for settings etc. small (easily overlooked) changes in formatting will
> break it, and you’ll have a support problem in teaching all those users
> how to write proper YAML. Don’t go there.
> Have a look at LuaRocks rockspec files for example on how you could
> leverage Lua for configuration files. You might even steal some code
> there.

  What's there to steal?  

	CONF = {}
	f = loadfile("config.lua","t",CONF)

  And CONF contains the contents of the configuration file.  In C, this
would be:


	rc = luaL_loadfile(L,"config.lua","t");
	if (rc == LUA_OK)
	  rc = lua_pcall(L,0,0,0);	/* we just loaded our config */

  -spc (BTW:  The code is for Lua 5.3)