cybersemics / em

A beautiful, minimalistic note-taking app for personal sensemaking.
Other
289 stars 121 forks source link

Generalize metaprogramming #1211

Open raineorshine opened 3 years ago

raineorshine commented 3 years ago

Metaprogramming attributes can be generalized into a hierarchical programming syntax.

Example

- =on
  - keyDown
    - meta
    - shift
    - d
  - =>
    - =subCategorize
    - =type
      - Done

// thoughts that start with = are interpreted as metaprogramming attributes as usual
// ineffectual in themselves but available for evaluation with the right user interaction
on({
  // non-leaf thoughts interpreted as objects
  keyDown: [
    // leaves in object property position interpreted as array items
    'meta', 
    'shift', 
    'd'
  ], 
  // lambda function given a generated key when expected to be an object property
  __lambda__0: () => {
    // lambda children interpreted as function body
    subCategorizeOne()
    // leaves of function interpreted as position arguments
    type('Done')
  }
})

Which would move a thought into a Done category when executed:

- To Do
  - Code Reviews

- To Do
  - Done
    - Code Reviews

Attributes

Attributes can be fully evaluated during rendering.

For example, instead of a simple scalar value:

- =note
  - hello em

A note could contain a dynamic expression:

- =note
  - =date
    - mm/d/yyyy // formats today's date

Or query other thoughts:

- =note
  - =concat
    - hello
    - /Friends/*[1]

which would evaluate to something like this:

'hello' + query('/Friends/*[1]')

Setting the note to 'hello' plus the value of the first thought in /Friends.

raineorshine commented 3 years ago

Discussion