Would type annotations not be a cleaner way of achieving
discrimination between types?

Would these APIs be redundant if we had type annotations?

On Mon, Aug 5, 2013 at 8:13 AM, Bruno Jouhier <bjouh...@gmail.com> wrote:
> From a dev standpoint what we need is a clean API to discriminate between
> types. Sometimes we want to discriminate between objects (mutable) and
> values (immutable), sometimes between functions and non functions, sometimes
> between numbers, strings and others, etc. And we don't want to have to write
> an extra test to exclude null from objects.
>
> As we cannot break the existing typeof and its little warts, could we
> introduce a new call, something like Object.typeInfo(x), that would return a
> little hash like:
>
> { type: "int64", immutable: true, number: true, ... }
> { type: "string", immutable: true, number: false, ... }
> { type: "array", immutable: false, number, false, ... }
>
> The idea it to have boolean flags like immutable/number/... to categorize
> types. This way we can discriminate by testing a flag instead of having to
> test complex combinations of typeof, Array.isArray, etc.
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to