nevalang / neva

🌊 Flow-based programming language with static types and implicit parallelism. Compiles to native code and Go
https://nevalang.org
MIT License
85 stars 7 forks source link

[STD] Separate "internal" components from just "global scope" ones #684

Open emil14 opened 1 week ago

emil14 commented 1 week ago

Problem

RN we have components like New, Lock or Field that are used by both user and compiler. Not just that might confuse user (which path to go?) but also mixes two separate responsibilities together

  1. Serve as implementation detail for compiler
  2. Serve as a tool for end user

For instance, user can set incorrect path to Field. Should field have err outport then? It's weird isn't it? Program should not compile if path is wrong. It's easy when we use syntax sugar . for that, but when we handle Field usage in a special case, that's a (unnecessary) special case for the compiler.

Proposal

Separate stuff like new, lock, field, etc (everything compiler uses for desugaring basically) from the ones that just should be available in the global scope.

Should something be in the global scope it's the question itself but for another issue.

The question that is related to this issue is - should user be able to use these "low-level" components at all? We can e.g. throw compilation error when user tries to import internal (e.g.) package.

Well, it's not clear. If we wanna go that way, we must be sure our syntax is good enough to cover all the cases needed. And even then, "syntax sugar" is a conception that mean - it must always be possible to write desugared version manually.

I see RN 2 solutions to this:

  1. It's not "desugared" version of the program, it's "lower level representation" (and user can't write it manually)
  2. Allow user to use internal but document it well so it's clear that it should not be done

Second approach is more flexible in a way that we can cover all the cases our syntax is not powerful enough (yet?). We can also add linter rule that will throw warnings on using unsafe/internal stuff.


Related to #683