nevalang / neva

🌊 Dataflow 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

Bytes parsing #27

Closed emil14 closed 7 months ago

emil14 commented 2 years ago

In Go it's possible to pass pointer to function that takes interface{} like json.Unmarshal:

var v struct{x int}

if err := json.Unmarshal(&v, []bytes{" {x:42} "}); err != nil {
  panic(err)
}

How to do this in FBP where we don't have pointers?

NOTE: this is fundamenal since almost any program gets its input from outside as bytes


emil14 commented 2 years ago

Constant solution

Create const node with predefined (empty?) struct and pass it to template port of genericjsonParse<T> component with bytes to data port.

const.struct = {x:42}

const.struct -> jsonParser
inports.bytes -> jsonParser
jsonParser.out -> outports.struct

Problem

It seems to be a synchronous approach - we don't parse data peace by peace