Open XandrosDarkstorm opened 10 months ago
You didn't explain what you think the bugs are, but I can guess. Bug 1 (line 3 of output): you are not setting the metamethods correctly. setdelegate() is required. This is squirrel 101 Bug 2 (lines 5 and 6): t.thearray is an array because the table get dereferences the weak reference so you can use it without knowing that it's a weak reference. if it were otherwise, t.thearray[0] would be nonsense because myweakref[0] is nonsense. What you want is t.thearray.weakref() which seems a bit crazy (is it a weakref to a weakref?) but no, it's the weakref itself (check SQRefCount::GetWeakRef() which returns the thing itself it it's actually a weakref). I don't blame you for getting this one wrong.
@zeromus Thank you for the explanation. I think i now understand what was wrong with my code. Weakref stuff was directly copy-pasted from the official documentation. Maybe this weakref.weakref() stuff needs to be mentioned there/corrected. Anyways, thanks again for your help.
hmmmm can you quote the exact part of docs at which URL?
http://www.squirrel-lang.org/doc/squirrel3.html#weakrefs
The code examples from gray zones never show "t.thearray.weakref()". It feels as if t.thearray is supposed to be its own object with "weakref" type.
Yes, that's what one would expect. But the docs say otherwise:
The table slot 'thearray' contains a weak reference to an array. The following line prints "first", because tables(and all other containers) always return the object pointed by a weak ref
t.theArray is "the object pointed to by a weak ref", not, "the weak ref".
This is SNEAKY and the docs could probably explain it better. But they do explain it. They would explain it better with a weakref.weakref()
example which would alert pretty much any reader to the complication of it all.
Sorry to all, I don't have suggested alternative docs at this moment.
Hello. I am trying to understand the difference between calling
type
andtypeof
in Squirrel 3.0.7 and i am having a hard time. Here is what i gathered so far:type
=type
" shows "function")typeof
=typeof
" results in an error "error expression expected".I used this code:
Please, help me understand: am i doing something wrong here or is it a bug?