[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Benefits of CSP Based Programming Languages

Neil, Oyvind,

> Somehow the compiler must know how many bytes are arriving.  It has
> knowledge of the protocol type so I presume it would be possible, even
> if at its simplest it just expanded to write the same code for every
> entry in the protocol.  It's just a suggestion though, I don't mean to
> be demanding features ;-)

It ought to be relatively easy, and potentially less memory hungry too, to
build it into the compiler. All it has to do is:

 - determine the max size of any protocol case and alloc a single buffer
that big
 - group the tags by size, and create tag-switch points for each size
 - for each size, code a resd-store-write operation.

There are obviously several implementations possible...

char buf[maxsize];

Tag.size = ...; // size of data associated with tag
switch (tag)
	Case clear.screen; // protocol includes "clear.screen; INT32:"

		// user code here

		// ?? shuffle data from 'param' above into buf,
		// or simply override location of 'param' to be an
		// alias into buf...
		Goto write.tag;

		Read(buf, tag.size);  
		Write(buf, tag.size);