observablehq / parser

The Observable parser.
ISC License
176 stars 27 forks source link

permit use of keywords in javascript expressions #208

Open trebor opened 1 year ago

trebor commented 1 year ago

currently, there are valid javascript expressions that use observables keywords mutable and viewof as identifiers that the observable parser will reject. the goal would be to allow these expressions where possible.

here are some examples of these identifiers that could be defined in a local cell scope:

{
  const viewof = 3;
}
function foo(viewof) { ... }

and at the notebook scope where cells can be named mutable and viewof:

function viewof() { ... }
viewof = 3

additionally, import semantics need to be worked out. what happens if a cell named viewof is imported from another notebook that defines it as a cell:

import { viewof } from "..."

this change is likely to alter logic in parse.js, and the Hello, Observable Parser notebook can be used to aid in testing.

broadly this change would be a preamble to possibly adding a builtin keyword to provide a namespace for all the built-in identifiers like width.