flowbased / flow-based.org

Flow-based programming specification wiki
https://flow-based.org
164 stars 5 forks source link

Automatic assignment of indices #22

Open jpaulm opened 9 years ago

jpaulm commented 9 years ago

In https://github.com/flowbased/flowbased.org/wiki/FBP-DSL , it says: "The javascript implementation of the parser assumes order of declaration as the index automatically, but this is not a characteristic of the DSL."

I assume this means that, if the parser knows that the port is an array port, and if the the port is somehow marked as an array, that the indices will be assigned automatically, unless explicitly overridden. How is the port marked as an array? I am guessing that you use empty square brackets, but, whatever you use, it should be spelled out explicitly.

Thanks in advance,

alfa256 commented 9 years ago

Let me explain, it works like this:

Foo OUT -> IN Bar
Foo OUT -> IN Zaz

Is the equivalent of:

Foo OUT[0] -> IN Bar
Foo OUT[1] -> IN Zaz

I do not know the reason for this, I just described what it does.

oleksandr commented 9 years ago

Explicit specification of a port index is part of the PEG grammar (https://github.com/noflo/fbp/blob/master/grammar/fbp.peg). I think a required order of declaration is a bad idea. At least in the Go version of FBP DSL (https://github.com/oleksandr/fbp) the indices should be specified explicitly and the order does not matter.

bergie commented 9 years ago

@oleksandr I think the automatic assignment unless specified is an artifact of original NoFlo handling of ArrayPorts, and shouldn't be part of the spec.

Of course, the problem is that the FBP parser doesn't really know anything about the components, and so can't throw a parse error on non-indexed connection with ArrayPort. But well-behaved FBP runtimes probably should.

jpaulm commented 9 years ago

Alex, I agree absolutely, this is a bad idea!

I can sort of see the logic for Alfredo's example, but consider the inverse:

Bar OUT -> IN Zaz Foo OUT -> IN Zazis either the equivalent of:

a) Bar OUT -> IN[0] Zaz Foo OUT -> IN[1] Zaz

or b) Bar OUT -> IN[0] Zaz -- which is basically the same as -> IN Zaz (FBP doesn't care!) Foo OUT -> IN[0] Zaz -- ditto

If b) is what you want, there is no way to force it, except by specifying

-> IN[0] Zaz

explicitly, which is counter-intuitive, as most of the time IN Zaz will not be an array!

On Sat, Sep 20, 2014 at 4:52 PM, Oleksandr Lobunets < notifications@github.com> wrote:

Explicit specification of a port is part of the PEG grammar ( https://github.com/noflo/fbp/blob/master/grammar/fbp.peg). I think a required order of declaration is a bad idea. At least in the Go version of FBP DSL (https://github.com/oleksandr/fbp) version the indices should be specified explicitly and the order does not matter.

— Reply to this email directly or view it on GitHub https://github.com/flowbased/flowbased.org/issues/22#issuecomment-56280013 .

oleksandr commented 9 years ago

@bergie I agree! And :+1: for the second point - the parser is just validating the given description against the grammar, the runtime is taking care of the rest...

@jpaulm Exactly! Well illustrated :)