[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: getting address of userdata
- From: "Matthew Armstrong" <turkeypotpie@...>
- Date: Mon, 21 May 2007 18:25:29 -0700
I'm pretty sure the 'No such operator defined' error is coming from luabind, as the userdata I'm running this on comes from a luabind created object.
If I temporarily remove the __tostring metamethod, the error goes away, so that solves my problem.
Another thing luabind does is override the __eq metamethod, to what it thinks == should be, which is a somewhat complicated definition. What if I want to compare two userdata objects solely based on whether the references are equal?
On 5/21/07, Peter Odding <xolox@home.nl> wrote:
Matthew Armstrong wrote:
> How do I get the address of a userdata object? This is solely for
> debugging
> purposes.
>
> For instance, if 't' is a table, and I say:
> print(t)
>
> It will say something like:
> table: 05AED8F0
>
> But, if I try that with a user data object, I get an error saying 'No such
> operator defined'.
I don't know where the message 'No such operator defined' is coming from, but
the default string representation for userdata in Lua 5.1 already includes an
address:
Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio
> = newproxy()
userdata: 00329758
> = tostring(newproxy())
userdata: 0032A9F8
> print(newproxy())
userdata: 0032ABF0
(I've used newproxy() as an example because it creates a userdata without a
__tostring() metamethod.)
- Peter Odding