Assignment to method invocation result

Jussi Kalliokoski jussi.kalliokoski at gmail.com
Fri May 16 07:53:19 PDT 2014


On 16 May 2014 15:08, "Rick Waldron" <waldron.rick at gmail.com> wrote:
>
>
>
>
> On Fri, May 16, 2014 at 1:55 AM, Tab Atkins Jr. <jackalmage at gmail.com>
wrote:
>>
>> On Thu, May 15, 2014 at 8:47 PM, Rick Waldron <waldron.rick at gmail.com>
wrote:
>> > I imagined .= would do both, but I don't think my suggestion should be
taken
>> > seriously. In fact, your example illustrates a major flaw (that exists
in
>> > either proposal/suggestion), that I don't immediately know how I would
>> > answer:
>> >
>> > var o = { foo: "bar" };
>> > o .= foo;
>> >
>> > Is `o` now a string with the value "bar"?? I think that would cause
more
>> > problems than its worth.
>>
>> Yes, that's exactly what it would do.  This sort of pattern is even
>> reasonably common when doing tree-walking, for example: you see a lot
>> of "node = node.left;" or whatnot.
>
>
> In your example, is it safe to assume that `node.left` is a node? I'm
familiar with this precedent on a daily basis ;) It was the "object becomes
a string" behaviour that I was objecting to.

I'm not a fan of objects becoming strings either, but that problem exists
with methods as well:

var foo = ["bar", "baz"];
foo .= join();

However, I don't think it's a problem introduced by this proposal, nor
addressible by it, but rather by something like guards:

var foo : Array = ["bar", "baz"];
foo .= join(); // Error

- Jussi

>
> Rick
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140516/955f2904/attachment.html>


More information about the es-discuss mailing list