nevalang / neva

🌊 Dataflow programming language with static types and implicit parallelism. Compiles to machine code and Go
https://nevalang.org
MIT License
127 stars 7 forks source link

Ideas for syntax sugar #471

Closed emil14 closed 8 months ago

emil14 commented 8 months ago
  1. Allow to omit DI node name when there's only one DI node
  2. Allow to omit single type parameter for type expressions, that would be any then
  3. Allow to omit std/ module prefix (can be implemented at the parser lvl)
  4. Allow to omit port-type, let it be any by default
  5. Allow to omit node name and use Entity's name by default but in lowerCamelCase (enforce names when there's two or more instances from the same entity)
  6. Allow to omit port name of the node when there's only 1 input and 1 output port (variant node is preferred to node: even though it's consistent with :start :stop syntax. It feels natural to "send message to printer", not to "printer node with unknown port". : Must stay for IO-node ports short syntax tho.
  7. Allow to avoid nodes and net sections in normal components in case it's obvious what entities are actually used. E.g. printer transforms to Printer that is std/builtin imported. Only for builtin components. Also not for interface nodes, they should be explicit.

This is how Nevalang could look

import {
  foo
  bar/baz
}

component Main(start) (stop) {
  :start -> ('hello world' -> printer)
  printer -> :stop
}
emil14 commented 8 months ago

About 7

Probably not builtin but instead simply "current scope"

Also what's with the type parameters when they are there? It's simple with Printer to have Printer<any> but how about entities with 2+ parameters? Would we insert any everywhere? What about parameters with real constraints tho?

A lot of questions

emil14 commented 8 months ago

Probably less radical approach could work.

  1. We still have nodes and net as separate sections
  2. We have the control over how printer Printer<any> node is created: we can change it's name, we have handle type arguments
import {
  foo
  bar/baz
}

component Main(start) (stop) {
  nodes { Printer }
  net {
    :start -> ('hello world' -> printer)
    printer -> :stop
  }
}