CONSTRUCT Dialect for Objects (Maps?)

Furthering this dialect... JavaScript has a shorthand, where if you use just a name, you can reference a variable and proxy its value into the object under that name:

const name = "Alice";
const age = 30;

// Traditional way
const person1 = {
  name: name,
  age: age
};

// Shorthand property names
const person2 = {
  name,
  age
};

console.log(person1); // { name: 'Alice', age: 30 }
console.log(person2); // { name: 'Alice', age: 30 }

Revolt has parts. Can do this too, why not use @WORD! (or @TUPLE!)?

let name: "Alice"
let age: 30

let person: {
  @name
  @age
}

probe person  ; &[object! [name: "Alice" age: 30]]

(Having the @ symbol for that makes it seem more in proportion to how weird what you're doing is. Plain WORD! for just spec'ing an empty field seems to fit better.)

2 Likes