Quirrel4.41.0

getobjflags

Global, available without an import
getobjflags(obj): int

Returns the engine flag bits stored on obj's reference.

Parameters

objanyany value

Return value

An int bit mask. The only bit currently defined is getconsttable().SQOBJ_FLAG_IMMUTABLE, set by freeze; a value that was never frozen reports 0.

Notes

The flags belong to the reference passed in, not to the underlying table or array: after let f = freeze(t), getobjflags(f) is nonzero but getobjflags(t) still reports 0, because t names the object through its own, never-frozen reference. See freeze for what that split means for writes.

Example

examples/globals/getobjflags.nut
let t = {}
println("getobjflags(t) =", getobjflags(t))

let f = freeze(t)
println("getobjflags(f) =", getobjflags(f))
println("getobjflags(t) =", getobjflags(t))   // t's own reference is unaffected by freezing f

println("getobjflags(5) =", getobjflags(5))   // any type is accepted; a scalar simply reports 0
Output:
getobjflags(t) = 0
getobjflags(f) = 1
getobjflags(t) = 0
getobjflags(5) = 0

See also

freezeReturns a reference to obj with the immutable flag set.
getconsttableReturns the const table.
globalsmodule index