Proposal: Inline javascript

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Proposal: Inline javascript

Abdul Shabazz
I would like to see a standard way of inlining javascript. 

For example: 

gpi <= theorem => basenet => supernet <= new Network().typeOf({ starTopology:[[0,1,..],[2,3,..],..] }), 

is syntactic sugar for: 

var theorem = []; 
theorem["basenet"] = [];
theorem["basenet"]["supernet"] = new Network().typeOf({ starTopology:[[0,1,..],[2,3,..],..] });
var gpi = theorem["basenet"]["supernet"];



...could you make it part of the standard?

Seagat2011,
--
Abdul S.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Inline javascript

T.J. Crowder-2
What specific advantages do you see this new syntax bringing compared to, say:

```js
var gpi = new Network().typeOf({ starTopology:[[0,1,..],[2,3,..],..] });
var theorem = [ "basenet": [ "supernet": gpi ] ]; 
```

...or with a sneaky assignment:

```js
var gpi, theorem = [ "basenet": [ "supernet": gpi = new Network().typeOf({ starTopology:[[0,1,..],[2,3,..],..] }) ] ];
```

...which do the same thing?

Does this call on any prior art?

What problems does it solve?

-- T.J. Crowder

On Tue, May 8, 2018 at 10:53 AM, Abdul Shabazz
<[hidden email]> wrote:

> I would like to see a standard way of inlining javascript.
>
> For example:
>
> gpi <= theorem => basenet => supernet <= new Network().typeOf({
> starTopology:[[0,1,..],[2,3,..],..] }),
>
> is syntactic sugar for:
>
> var theorem = [];
> theorem["basenet"] = [];
> theorem["basenet"]["supernet"] = new Network().typeOf({
> starTopology:[[0,1,..],[2,3,..],..] });
> var gpi = theorem["basenet"]["supernet"];


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Inline javascript

Isiah Meadows-2
Also, it's not like you can't emulate this at the language level:

```js
function setIn(object, path, value) {
    return path.slice(0, -1)
        .reduce((o, p) => o[p], object)
        [path[path.length - 1]] = value
}

const gpi = setIn(object, ["basenet", "supernet"],
    new Network().typeOf({ starTopology: [[0, 1, ..], [2, 3, ..],..] })
)
```

Lodash has a variant of this in its [`_.set`][1] method, which returns
the object rather than the operand. The equivalent to that would be
this:

```js
const gpi = new Network().typeOf({ starTopology: [[0, 1, ..], [2, 3, ..],..] })

_.set(object, "basenet.supernet", gpi)
```

[1]: https://lodash.com/docs#set

-----

Isiah Meadows
[hidden email]
www.isiahmeadows.com

On Tue, May 8, 2018 at 9:41 AM, T.J. Crowder
<[hidden email]> wrote:

>
> What specific advantages do you see this new syntax bringing compared to, say:
>
> ```js
> var gpi = new Network().typeOf({ starTopology:[[0,1,..],[2,3,..],..] });
> var theorem = [ "basenet": [ "supernet": gpi ] ];
> ```
>
> ...or with a sneaky assignment:
>
> ```js
> var gpi, theorem = [ "basenet": [ "supernet": gpi = new Network().typeOf({ starTopology:[[0,1,..],[2,3,..],..] }) ] ];
> ```
>
> ...which do the same thing?
>
> Does this call on any prior art?
>
> What problems does it solve?
>
> -- T.J. Crowder
>
> On Tue, May 8, 2018 at 10:53 AM, Abdul Shabazz
> <[hidden email]> wrote:
> > I would like to see a standard way of inlining javascript.
> >
> > For example:
> >
> > gpi <= theorem => basenet => supernet <= new Network().typeOf({
> > starTopology:[[0,1,..],[2,3,..],..] }),
> >
> > is syntactic sugar for:
> >
> > var theorem = [];
> > theorem["basenet"] = [];
> > theorem["basenet"]["supernet"] = new Network().typeOf({
> > starTopology:[[0,1,..],[2,3,..],..] });
> > var gpi = theorem["basenet"]["supernet"];
>
>
> _______________________________________________
> es-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss