Code: Select all
true
EDIT: I haven't tested it because I'm in class, but I bet it will work if I require inside of the entered callback instead of on a file scope level.
EDIT2: Nope. Also didn't make any sense when I put it in code.
Code: Select all
true
Code: Select all
local Shmup = require 'lua.shmup'
Code: Select all
local _path = ({...})[1]:gsub("%.init", "")
return require( _path .. '.Shmup' )
Once a loader is found, require calls the loader with a single argument, modname. If the loader returns any value, require assigns the returned value to package.loaded[modname]. If the loader returns no value and has not assigned any value to package.loaded[modname], then require assigns true to this entry. In any case, require returns the final value of package.loaded[modname].
Code: Select all
self.super.class.initialize(self, params)
Code: Select all
self.class.super.initialize(self, params)
Code: Select all
require 'middleclass'
Test1 = class("Test1")
Test2 = class("Test2", Test1)
Test3 = class("Test3", Test2)
function Test3:initialize(params)
self.class.super.initialize(self, params)
end
local obj = Test3:new()
Code: Select all
self.class.super.initialize
Code: Select all
Test2.initialize(self, params)
Code: Select all
require "middleclass"
local Test1 = class("Test1")
local Test2 = class("Test2", Test1)
local Test3 = class("Test3", Test2)
function Test1:initialize(params)
end
function Test2:initialize(params)
self.class.super.initialize(self, params)
end
function Test3:initialize(params)
self.class.super.initialize(self, params) -- go in infinite recursion call
end
local t = Test3{}
Code: Select all
Copyright (C) 2009-2011 A n s c a , I n c .
Version: 2.0.0
Build: 2011.704
The file sandbox for this project is located at the following folder:
(/Users/sergey/Library/Application Support/Corona Simulator/engine-2419A65E500758E2AE1AF33CF8CAA007)
Runtime error
/Users/sergey/projects/engine/main.lua:50: stack overflow
stack traceback:
[C]: ?
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
...
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:53: in function 'initialize'
/Users/sergey/projects/engine/middleclass.lua:90: in function </Users/sergey/projects/engine/middleclass.lua:88>
(tail call): ?
/Users/sergey/projects/engine/main.lua:56: in main chunk
Runtime error: /Users/sergey/projects/engine/main.lua:50: stack overflow
stack traceback:
[C]: ?
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
...
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:50: in function 'initialize'
/Users/sergey/projects/engine/main.lua:53: in function 'initialize'
/Users/sergey/projects/engine/middleclass.lua:90: in function </Users/sergey/projects/engine/middleclass.lua:88>
(tail call): ?
/Users/sergey/projects/engine/main.lua:56: in main chunk
Code: Select all
obj:invoke('method',...)
Code: Select all
obj:method(...)
I'm guessing because with invoke you can pass it a variable string that gets invoked.Roland_Yonaba wrote:Hi,
I was wondering about the use of Invokermixin, by itself.
Basically, it calls a method or a property of an instance.
But why would one do:
instead ofCode: Select all
obj:invoke('method',...)
I don't see the point. Maybe you can provide me some examples ?Code: Select all
obj:method(...)
And by the way, I guess the error messange on checking MiddleClass should be corrected ('Please require it before using Invoker, not Beholder').
Users browsing this forum: No registered users and 8 guests