Recent Changes - Search:

* PCAN

* Phix

edit SideBar

Object

Index | Library Routines | Predefined Types | object

object

Definition: object identifier

-- or -- integer i = object(object x)

Description: This serves to define the object type.

You can also call it like an ordinary function to test if x is of type object. This will always be true for all legal values of x, be that integer, atom, string, or sequence, so object() will always return 1, except when x is unassigned.

Comments: All predefined and user-defined types can also be used as functions to test if a value is legal for that type.

In previous versions of Phix, object(x) would crash when x was unassigned, but now yields 0.

Example:
? object({1,2,3})   -- always prints 1
Implementation: There is a generic version of the object function implemented as :%opObj in builtins\VM\pType.e that the compiler only invokes as a last resort, preferring instead to inline that functionality if the argument is known to be assigned or the result variable, if any, is known to be an integer, ie does not require decref/dealloc. The compiler may also completely omit the test and/or any related code, if type inference/propagation determines that the result will always be true or always false.
See Also: atom, integer, sequence, string, Core Language

< string | Index | Sequence Manipulation >

Edit - History - Print - Recent Changes - Search
Page last modified on April 16, 2026, at 10:58 AM