lua-users home
lua-l archive

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

>   function instance:htmlize_link(link)
	So, this function needs two parameters: an object and a link!

Ah. I knew there was some small subtleties lurking somewhere. I discovered that the capture was sent to htmlize_link as the self argument just a few minutes ago.

	To solve this, you should create another function:

self.Data = gsub(self.Data, "%[([^]]*)%]", function (link)
	%self.htmlize_link (%self, link)

Of course. It would have been simpler to just reference the function as self:htmlize_link and let that statement imply that self is to be prepended to the argument table during execution. Maybe it's possible to change the Lua language to enable this approach without any nasty semantic problems...?

Why %self instead of self by the way?

	On the other hand, the function htmlize_link doesn't
need the object and you can redefine it:

function instance.htmlize_link (link)

	And maintain the same gsub call.

Agreed, to make htmlize_link() a "method" of a page "object" is even questionable in a strict OOP sense since it operates on a link, but still. :-)

/ Sebastian Rasmusse

MSN Photos is the easiest way to share and print your photos: