Rick Waldron wrote:
The monocle shines here... (comments inline)

?

On Mon, Jan 23, 2012 at 1:43 PM, Herby Vojčík <[email protected]
<mailto:[email protected]>> wrote:

    Hello,

    not very often, but also not very rare, is there the case of this
    kind of code:

      var result = {
        model: model,
        seats: seats
      };
      if (space) {
        result.truck = true;
        result.space = space;
      }


var result = {
       model: model,
       seats: seats
     };
if ( space ) {
   result.{
     truck: true,
     space: space
   }
}

Yes, but it is just a little more dataized version of the code before. The intent of the programmer is not to create a constant-structure harness and then (however elegantly) patch it afterwards, it is to create one data structure with some parts conditional.

The code above is till too imperative - it is really carrying out the if statement and the doing whatever one pleases inside (so one must scan if it really is only result.{...}), and has one level of nesting more.

If the form below, you cannot do whatever you please inside then-body or else-body - just put there the nested data-production.

    Object literal extension (and get/set before them) have shown that
    blocks can be used in object literal.

    I propose to have possibility to write

      var result = {
        model: model,
        seats: seats,
        if (space) {
          truck: true,
          space: space
        }
      };

    in object literal, and similar possibility of conditional definition
    in the body of a class.

    Herby

Herby

P.S.: And, well, this is not the only thing I have in mind, but if I post whatever longer, I got tl;dr-ed. I drew more inspiration from code structures that can be useful by porting to data side, having the same semantics, but descriptive instead of imperative nature. But I must go one by one.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to