Packets & Pointers

37 views
Skip to first unread message

Rob Halff

unread,
Jan 26, 2015, 6:11:36 PM1/26/15
to flow-based-...@googlegroups.com
Lectori salutem,

I have this idea about adding pointers to packets, somewhat implemented it and the concept seems to work in tiny tests.

In order to test the idea I've fabricated some custom .fbp:

{
 
"title": "my title",
 
"test": true
} -> in Accept(some/object) out -(/title)> in Reverse(string/reverse)

Reverse out -> msg Log(console/log)  # outputs: "eltit ym"

Reverse out -()> msg Log             # outputs: { "title": "eltit ym", "test": true }

While I'm using javascript, the pointers are defined as JSON Pointers: http://tools.ietf.org/html/rfc6901
But I can imagine different types of pointers being used for other languages.

In the above the `/title` defined on the edge sets the pointer (or head) to title, which makes the packet
content appear as that string instead of the underlying object.

The () in the third line is an empty pointer, which puts the pointer to the root again.
This means a complex structure can pass through parts of a network as long as one of it's parts
match the correct structure.

This also enables attaching any kind of extra information to the packet and hide it by moving the pointer to somewhere else
within the packet.

This content can then be recalled anywhere within the network at a later stage by adjusting the pointer.

A next step would be masking/masquerading instead of just moving the pointer and representing the structure
as something totally different.

I'm curious whether the above construction makes sense to other fbp implementers.

It could be I'm trying to solve a problem which does not exist in other fbp implementations,
so if the above causes nothing but frowns, please enlighten me.

Greetings,
Rob Halff



Humberto Madeira

unread,
Jan 27, 2015, 9:38:44 AM1/27/15
to flow-based-...@googlegroups.com
Hi Rob,

I believe understand what you are trying to do, but I believe it can be done more simply in Javascript,
providing that you take advantage of the fact that Javascript is actually not object-oriented.

So, say I have a string object, e.g.

var funnyString = new String("funny");

I can add anything I want to it, and it will be carried along.

funnyString.rider= "another";

funnyString this will be accepted and passed through by anything that accepts Strings, but anytime you want, you can access the rider.

function getRider(possiblyFunnyString)
{
   if(possiblyFunnyString.rider)
      return possiblyFunnyString.rider;
}

So to implement your "pointer" concept, just map a bunch of objects, and then add the map as a rider to each object

var riderMap = {};
ridermap["main"]=new String("funny");
ridermap["main"].rider = riderMap;
ridermap["alt"]=new String("another");
ridermap["alt"].rider = riderMap;

Now get a "pointer" to one of the objects

var pointer = ridermap["main"]; // this is a much faster lookup than JSon Pointers.

If you pass the pointer around, it will go anywhere that Strings go.

However, at any time you can do this... (after verifying it has a rider)

pointer = pointer.rider["alt"]; // or pointer = pointer.rider.alt; 

and now the pointer can also be passed around like any other String, but with the other value.

This pointing technique can be used with any object types in Javascript, just not the primitives.
You can point to objects that are considered separate, or to objects that are already inside a hierarchy of some sort, it doesn't really matter.
And you don't need to drag in any additional Javascript libraries.

Regards,
--Bert
Reply all
Reply to author
Forward
0 new messages