Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eval-syntax #74

Open
DrSensor opened this issue Sep 23, 2023 · 1 comment
Open

eval-syntax #74

DrSensor opened this issue Sep 23, 2023 · 1 comment
Labels
data binding Everything related to data binding enhancement New feature or request experimental Breaking changes can happen at any time priority: low Low hanging issue. Might not worth to tackle it now.

Comments

@DrSensor
Copy link
Owner

DrSensor commented Sep 23, 2023

Expose an eval syntax. Similar to new Function() (used by AlpineJS) or eval() but doesn't expose global variable and Web API. Also no new variable creation a.k.a let or const. No declaration, no statement, no loop. It just an expression. However, it may have ternary operation and range/slice bound.

Some ideas:


Operator that exclusive for string, list/array, and vector/matrix are denoted in [ops]. There's some ops-syntax borrowed from other lang.

concat (inspired by Lua)

<span ~ #text="
  ret:sepByComma<~`(scale3d[..][0,0,0])
"></span>

same as

span.textContent = sepByComma(
  scale3d.concat([0, 0, 0])
)

scalar add on vector

<span ~ #text="
  ret:sepByComma<~`(scale3d[+]5)
"></span>

same as

span.textContent = sepByComma(
  scale3d.map(it => it + 5)
)

addition between vector

<span ~ #text="
  ret:sepByComma<~`(scale3d[+]pos2d)
"></span>

roughly same as

span.textContent = sepByComma(
  Array.from(
    { length: Math.max(scale3d.length, pos2d.length) },
    (_, i) => (scale3d[i] ?? null) + (pos2d[i] ?? null),
  )
)

Note that to enter eval-syntax, the expression should be wrapped in `()

@DrSensor DrSensor added data binding Everything related to data binding enhancement New feature or request experimental Breaking changes can happen at any time priority: low Low hanging issue. Might not worth to tackle it now. labels Sep 23, 2023
@DrSensor
Copy link
Owner Author

DrSensor commented Sep 23, 2023

Not related to eval-syntax but from the example seems I got a design issues in the implementation detail of rust (and potentially other) binding.

use libnusa::{number, Vector, Null};

#[no_mangle]
fn sepByComma(
  list: Vector<Null<number::f32>>
  // okay so where to store this temporary value? 
  // which memory?
  // which offset?
) {}

Should I treat it as Buffer 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data binding Everything related to data binding enhancement New feature or request experimental Breaking changes can happen at any time priority: low Low hanging issue. Might not worth to tackle it now.
Projects
None yet
Development

No branches or pull requests

1 participant