Talk:User defined pipe and redirection operators: Difference between revisions

m
Line 14:
Adhere to the syntax of the specific language where required, eg the use of brackets and names of operators.
 
For example: I had to use the operator "=:" instead of athe standard "|" pipe-char as the pipe"|" characterchar has a special (and fixed and unchangeable) meaning in Algol68. (I could have used [[wp:Douglas McIlroy|Douglas McIlroy]]'s "^" char for piping maybe? but =: reads better.)
 
Here is the "''Sample shell script''", but rewritten in Algol.
Line 48:
This task should be OK in python, especially the operators, and also Ada. I figure the GNU C has a fair chance. C++ should be able to handle the operator overloading.
 
I'm not familiar enough with other languages to make any real comment. [Ocaml can do any thing! (apparently)] :-) ... Go should be real interesting!
 
BTW: Here is a complete implementation of "''tail''", notice it uses a sliding window:
Line 76:
OP TAIL = (INT n)MANYTOONE: tail(n,);</lang>
 
Note that this "''tail''" implementation requires just one argument "n", keeping things simple to satisfy the use of tail in the "''Sample shell script''". I'mThe task is not asking for reinvention of head/tail etc,. just enough to run the "''sample shell script''" while retaining the basic functionality of the cloned shell utility, basically just a proof of concept for a particular language.
 
'''Rationale''': Pipes appear in a hoard of different languages. It always bugs me when a feature is '''cemented''' into a language and hence cannot enhanced. Being such a wide spread and useful concept, it would be nice to simply define a few new operators and have piping/redirection available in anythe othernew language.
 
Indeed, having to the ability to add pipes & redirections to a language means a coder can evolve the pipe/redirection definition to match the environment. For example the pipe/redirection operators defined above are "[[Strong typing|string typed]]" (currently STRING'''string'''), hence the compiler will detect data of the wrong type (currently '''string''')being piped to the wrong "coprocedure" and report with a '''compile time''' semantic error, hence one [[Unit_testing|unit test]] script just wrote itself!! (joy).
 
[[User:NevilleDNZ|NevilleDNZ]] 03:1026, 13 September 2011 (UTC)