Proposal: Inline javascript

# Abdul Shabazz (6 years ago)

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"];

I have developed tools to do this: Seagat2011/JSCASETool-JINSIL-JINT-Bluebird-

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

Seagat2011,

# T.J. Crowder (6 years ago)

What specific advantages do you see this new syntax bringing compared to, say:

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

...or with a sneaky assignment:

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

# Isiah Meadows (6 years ago)

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

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 method, which returns the object rather than the operand. The equivalent to that would be this:

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

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

Isiah Meadows me at isiahmeadows.com, www.isiahmeadows.com