Inroduce - "...." or "from" - keyword, for call chain inference

// If I know Color is a property - not sure where, 
// somewhere up the call chain, why not introduce 
// a keyword which infers it

let RGB = {
    Color: "red",
}
let ColorTint = {
    Color:RGB,
}
let Seed = {
    ColorSpace:ColorTint,
}
let Apple = {
    Seed: Seed,
}

let AppleTree = {
    Fruit: Apple,
}

let color = Color from Apple in AppleTree // AppleTree.Apple.Seed.ColorSpace.ColorTint.Color //

β€œwhy not” may not be as important a first question as β€œwhy”?

Your proposed syntax is very confusing to me; as a reader (the far, far more important audience than the writer) i have absolutely no idea what’s happening here. What problem is this solving, besides saving a few characters?

1 Like

The other solution to this problem would be to just have the API designer structure their objects to be less nested and more flat.

In an ambiguous case, what value would be returned?

let obj = {
  A: { target: 'this one' },
  B: { target: 'that one' }
};

console.log(target from obj); // what gets logged?
3 Likes

You do realize the computational complexity in finding that value, right? Also, I get with vibes out of this, particularly if you nested a with inside of a with.