Objects stringification

This document is Work In Progress.

State of this Document


On September 4th 2010 , the question has been raised on the Haxe mailing-list how objects were stringified by Std.string.

At the moment, there's nothing in the specifications that describe how Std.string should work, the goals of this document is to know how it's implemented in different platforms and then to decide what should become the standard.

State of Std.string


This section aims at suming-up how Std.string is implemented across platforms. This is needed to evaluate differences and to get new ideas about what could be improved. This will also be important when evaluating the needed amount of work to implement a new standard.

JavaScript


Null value


The null value are represented by the "null" string.

Functions


Functions are represented by the "<function>" string.

Strings


Strings are represented by their own value.

Arrays


Arrays are represented by the representations of values stored in it, separated by commas, and put inside square-brackets:
["Hello", 12, "World"]

Enums


Objects


As a default they will be represented by the "[object Object]" string, but if they do define a toString function, this function will be called and its return value will be used to represent the object.

Hashes


Hashes are represented by the following type of string:
{
    key1 : ValueRepresentationOfKey1, 
    key2 : ValueRepresentationOfKey2
}
version #9215, modified 2010-09-05 23:41:16 by bdasnois