
=encoding utf8

=head1 NAME

Sidef::Object::Object

=head1 DESCRIPTION

This class is the base class for all Sidef objects. It provides fundamental methods for object introspection, cloning, method manipulation, output, and smart matching.

=head1 SYNOPSIS

var obj = Object()


=head1 INHERITS

Inherits methods from:

       * Sidef::Object::Convert

=head1 METHODS

=head2 !~

    a !~ b

Returns the negation of the smart match operator. Returns C<true> if C<a> does not smart match C<b>.

=cut

=head2 &&

    a && b

Logical AND operator. Returns C<b> if C<a> is true, otherwise returns C<a>.

=cut

=head2 :

    a : b

Creates a Pair object from C<a> and C<b>. This is a deprecated alias for the pair operator.

=cut

=head2 \\

    a \\ b

Defined-OR operator. Returns C<b> if C<a> is defined, otherwise returns C<a>.

=cut

=head2 ^

    a ^ b

Logical XOR operator. Returns C<true> if exactly one of C<a> or C<b> is true, otherwise returns C<false>.

=cut

=head2 |>

    a |> b

Pipeline operator.  Passes C<a> as the first argument to function or method C<b>. If C<b> is an array, the first element is used as the function and the remaining elements as additional arguments.  If C<b> is a string, it is treated as a method name to call on C<a>.

=cut

=head2 ||

    a || b

Logical OR operator. Returns C<a> if C<a> is true, otherwise returns C<b>.

=cut

=head2 ~~

    a ~~ b

Smart match operator.  Performs context-sensitive comparison between C<a> and C<b> based on their types:

=over 4

=item * Two undefined values:  returns C<true>

=item * Object ~~ TypeName: returns C<true> if object's type is a subclass of TypeName

=item * String ~~ RangeString: returns C<true> if string is contained in range

=item * Number ~~ RangeNumber: returns C<true> if number is contained in range

=item * Array ~~ Array: returns C<true> if arrays are equal

=item * Array ~~ Regex: returns C<true> if any element matches the regex

=item * Array ~~ Hash: returns C<true> if hash contains all array elements as keys

=item * Array ~~ Any: returns C<true> if array contains the value

=item * Hash ~~ Array: returns C<true> if array contains all hash keys

=item * Hash ~~ Hash: returns C<true> if hashes are equal

=item * Hash ~~ Regex: returns C<true> if any key matches the regex

=item * Hash ~~ Any: returns C<true> if hash contains the key

=item * Regex ~~ Array: returns C<true> if any element matches the regex

=item * Regex ~~ Hash: returns C<true> if any key matches the regex

=item * Regex ~~ Any: returns C<true> if regex matches the value

=item * Any ~~ Block: calls the block with the value and returns the result

=back

Aliases:  I<smartmatch>

=cut

=head2 ⫶

    a ⫶ b

Creates a NamedParam object from C<a> (the name) and C<b> (the value). Uses the Triple Colon Operator (U+2AF6).

=cut

=head2 ：

    a ： b

Creates a Pair object from C<a> and C<b>.  Uses the Fullwidth Colon (U+FF1A).

=cut

=head2 alias_method

    self. alias_method(old, new)

Creates an alias C<new> for the existing method C<old> on the object's class. Dies if the method C<old> does not exist.  Returns the object.

=cut

=head2 bless

    obj.bless(arg)

Blesses C<arg> into the class of C<obj> and returns the blessed reference.

=cut

=head2 class

    obj.class

Returns the short class name of the object (the part after the last C<::>). For example, C<Sidef::Types::Number::Number> would return C<"Number">.

=cut

=head2 clone

    obj.clone

Returns a shallow copy of the object.  For hash-based objects, creates a new hash with the same key-value pairs. For array-based objects, creates a new array with the same elements.

=cut

=head2 dclone

    self.dclone

Returns a deep copy of the object, recursively cloning all nested hash and array structures.  Handles circular references by tracking already-cloned objects.

Aliases: I<deep_clone>

=cut

=head2 def_method

    self.def_method(name, block)

Defines a new method with the given C<name> on the object's class.  The C<block> will be called with the object and any arguments when the method is invoked. Returns the object.

=cut

=head2 dump

    self.dump

Returns a string representation of the object suitable for debugging. For hash-based objects, includes all key-value pairs in the format C<ClassName(key:  value, ...)>. Handles circular references.

=cut

=head2 interpolate

    self. interpolate

Creates a new object of the same class by joining the provided arguments into a string. Used for string interpolation.

=cut

=head2 is_a

    self.is_a(obj)

Returns C<true> if the object is an instance of C<obj> or inherits from C<obj>, otherwise returns C<false>.

Aliases: I<is_an>, I<kind_of>

=cut

=head2 is_object

    self.is_object

Returns C<true> if the value is an instantiated object (a reference), otherwise returns C<false>.

=cut

=head2 is_typename

    self.is_typename

Returns C<true> if the value is a typename (not an instantiated object), otherwise returns C<false>.

=cut

=head2 lazy

    self.lazy

Returns a Lazy object wrapping the current object.  The lazy object defers method calls until the result is actually needed.

=cut

=head2 method

    self.method(method, *args)

Returns a LazyMethod object that, when called, will invoke the named C<method> on the object with the given C<args>.  Useful for creating method references with bound arguments.

=cut

=head2 methods

    self.methods(*args)

Returns a Hash of all public methods available on the object.  Each value is a LazyMethod object bound to the object with the given C<args>.

=cut

=head2 new

    self.new

Creates and returns a new empty Object instance.

=cut

=head2 parent_classes

    obj.parent_classes

Returns an Array of all parent classes (superclasses) that the object's class inherits from, recursively traversing the inheritance hierarchy.

=cut

=head2 print

    self.print

Prints the object to standard output without a trailing newline. Returns C<true> on success, C<false> on failure.

=cut

=head2 ref

    obj.ref

Returns the full class name (package name) of the object as a String. For example, C<Sidef::Types::Number::Number>.

=cut

=head2 refaddr

    self.refaddr

Returns a Number representing the memory address of the object reference.  Useful for comparing object identity.

Aliases: I<object_id>

=cut

=head2 reftype

    self. reftype

Returns a String representing the underlying reference type of the object (e.g., C<"HASH">, C<"ARRAY">).

Aliases: I<object_type>

=cut

=head2 respond_to

    self.respond_to(method)

Returns C<true> if the object has a method with the given name, otherwise returns C<false>.

=cut

=head2 say

    self.say

Prints the object to standard output followed by a newline.  Returns C<true> on success, C<false> on failure.

Aliases: I<println>

=cut

=head2 to_json

    self.to_json

Converts a Sidef object into a JSON string.

    say Hash(
        "active" => true,
        "name" => "Sidef",
        "year" => 2013,
    ).to_json

Output:

    {"name":"Sidef","active":true,"year":2013}

=head2 undef_method

    self.undef_method(name)

Removes the method with the given C<name> from the object's class. Returns the object.

=cut
