Group: comp.lang.forth · Group Profile
Author: Bruce McFarlingBruce McFarling Date: Apr 5, 2008 07:56
On Apr 5, 10:30 am, Jonah Thomas gmail.com> wrote:
>>> It would need to be maintained, but that might not be onerous.
>> ... but far better a solution where the maintenance is a side effect
>> of something else. Someone builds a toolkit in Forth to simplify
>> scripting an external library, they build the four stream interface to
>> simplify using the script over a network, the language binding for
>> niche language "X" automatically inherits access to the toolkit via
>> the four stream interface.
> Yes, that sounds good. Could you set up the Forth side so there's a
> mostly-standard format for source code to follow, or is that pretty much
> hopeless?
Could you set up what part on the Forth side?
I think that more than two decades of command-line interfaces tell us
a workable approach for the command:acknowledge I/O pair of streams:
command:
action { -o option1 --option=option2 } { operand }
... and setting up a parser that starts with the default values for
that action, fills in the optional values that are specified, then
applies the action to the operand is something that is
straightforward. With that parser in hand, its just a matter of
writing and testing the individual "action" words and putting them in
the wordlist that is handed to the command-stream handler.
acknowledge:
message-type: message
... and that is even simpler, to define acknowledgment words that
either take or generate a string, and emit their message type before
passing the string to the acknowledge-stream.
... and of course stdin/stdout as key/emit is a long established
practice in Forth's for *nixen.
Just about any language that can execute an external application
through a command-line operating system shell would have at least most
of what is needed to hook up to that socket. Then its a matter of
either using the standard socket system for the operating system or
developing one to suit.
... beyond that, given the massive number of potential libraries and
applications to bind to, and the massive variety of types of problems
that they are solving, I'd reckon its a buffet ... if person A offers
a binding and person B doesn't like that design, then its better for
person B to re-use what they like and redesign what they don't than to
try to work out a vanilla standard for how those kinds of bridges
should work behind the four-stream connection layer.
|