Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow object as string #243

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Allow object as string #243

wants to merge 3 commits into from

Conversation

gfx
Copy link
Member

@gfx gfx commented Aug 25, 2013

object as string is useful in cases the object overrides toString() and/or the type of the object is specified by a type parameter (e.g. function f.<T>(value : T) : void { log "label: " + value as T; }).

as a (logically) shortcut of `o != null ? o.toString() : "null"`
tested in t/compile_error/144.null-as-primitive.jsx
@kazuho
Copy link
Member

kazuho commented Aug 26, 2013

Thank you for the work. I am mostly fine with the idea.

But I wonder what happens when both this change and the auto-stringification in + (concatenation operator) gets introduced.

The discussion about the auto-stringification was that as string in the following snippet should be omittable.

var s = "abc";
var n = 123;
var ret = s + n;

And if we add the feature together with this change, it would mean auto-stringification would occur for any type of data. Do you think it is affordable?

@ghost ghost assigned nyuichi Sep 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants