[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];

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

		// 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;

	Default:
		Read(buf, tag.size);  
Write.tag:
		Write(buf, tag.size);
}




Ruth