Page 1 of 1

Can't call Sleep() from withing _get() metamethod

Posted: 07 Feb 2010 23:15
by Zutty
Hi all,

I have found that I am unable to call AIController.Sleep() from within the _get() metamethod of a class. Is this expected behaviour?

The following snippet should demonstrate this (tested in r19055)

Code: Select all

class foo {
	function _get(x) {
		::AIController.Sleep(1)
	}
}
foo().bar
I cant see any reason why this would be forbidden, unless I'm missing something. Please tell me this is a bug, that you can fix before 1.0 is released! :D Please please please!

As for why I want this, I'm trying to create a dynamic Proxy class for a little bit of AOP, to streamline my codebase a little bit.

Thanks very much

Re: Can't call Sleep() from withing _get() metamethod

Posted: 07 Feb 2010 23:27
by Rubidium
If I recall correctly executing those metamethods are implemented by 're-entering' the virtual machine (think of recursion) via a piece of C++ code. A we cannot suspend the C++ code we cannot suspend the virtual machine if called in that way, as such no sleeps or docommands are allowed. Changing this means basically rewriting the Squirrel implementation, which is very unlikely to happen..

Re: Can't call Sleep() from withing _get() metamethod

Posted: 08 Feb 2010 13:46
by Zutty
Ah damn, nevermind. I'll find some other way of doing it then. Thanks Rubidium.

Re: Can't call Sleep() from withing _get() metamethod

Posted: 12 Feb 2010 12:35
by Blustuff
The SquirrelVM is awful.

Re: Can't call Sleep() from withing _get() metamethod

Posted: 12 Feb 2010 19:00
by SirkoZ
Blustuff wrote:The SquirrelVM is awful.
Please, provide a better one. It will be greatly appreciated.

Re: Can't call Sleep() from withing _get() metamethod

Posted: 15 Feb 2010 12:45
by Blustuff
SirkoZ wrote:Please, provide a better one. It will be greatly appreciated.
I'm on it. 'will take one year or two.