Module talk:ScribuntoUnit: Difference between revisions

Content deleted Content added
m <tt>...</tt> → {{mono|...}}
m Replaced deprecated <source> tags with <syntaxhighlight> (via WP:JWB)
 
Line 30:
: Hm, how does it fail? I tried using mw.title at [[Module_talk:ScribuntoUnit/showcase]], and it seems to work, but I'm not familiar with it. – ''[[User:Danmichaelo|Danmichaelo]] ([[User talk:Danmichaelo|talk]])'' 18:47, 5 January 2014 (UTC)
:: You used the mw.title library, rather than a title object. To get a title object you need to use code like <code>mw.title.new('Wikipedia:Sandbox')</code>. I tried doing just that in the showcase module, and the whole script fails with a "not enough memory" error. The problem is that some of the title object fields are self-references. For example:
<sourcesyntaxhighlight lang="lua">
local sandbox = mw.title.new('Wikipedia:Sandbox') -- title object for [[Wikipedia:Sandbox]]
sandbox.basePageTitle -- Also the title object for [[Wikipedia:Sandbox]]
sandbox.basePageTitle.basePageTitle -- Again, the same title object.
</syntaxhighlight>
</source>
:: So if you try and iterate recursively through any given title object, while respecting metatables, you will just keep on going forever. Scribunto then dies when it runs into the memory limit. This problem has been resolved somehow in mw.logObject, but I haven't looked deeply enough at the code to know exactly what was done. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 11:06, 6 January 2014 (UTC)