Conversational programming in Perl for EMC
Posted by
Fred Proctor
on 2000-05-09 12:42:09 UTC
Ron Ginger wrote about wanting to write a conversational programming
interface in Perl. He wrote that the Visual Basic and Tcl/Tk data types
are too limiting:
of data structures. It uses strings for some of the return values, and
the usual scalar data types (ints, doubles) for the rest. Perl could be
much better:
emc/src/emctask/emcsh.cc, and does the so-called "impedance matching"
that maps strings encountered in a Tcl/Tk script (e.g., "emc_estop on")
to some C++ code that composes and writes the corresponding message to
the EMC command buffer. emcsh.cc starts by connecting to the EMC, then
calls a C++ function in the Tcl/Tk library that enters a main loop that
prints a prompt, reads input, parses it, and interprets it according to
the Tcl/Tk syntax and whatever you added to it in string-function pairs.
Something equivalent can be done in Perl. I have never done this, but I
see from the O'Reilly Perl book, 2nd Edition, on page 371 that there are
references to man pages for perlxstut, perlxs, perlguts, and perlcall
that describe this. XS is a preprocessor that spits out the glue
routines that tie C++ into Perl.
Rather than waiting for me to never get around to it, this could be a
plan for Perl-ifying the EMC:
1. Someone with Perl experience extends Perl with a C++ function that
just increments its argument, e.g.,
int myfunc(int arg)
{
return arg + 1;
}
and then does the gluing to the string "myfunc" so if you do this in a
Perl script:
print myfunc(2)
it prints 3. Forgive my Perl syntax.
2. Once this is done, get it to the emc@... list with notes on what
you did, and we'll clone the glue code to handle comm channels, etc. and
populate it with a representative set of EMC functions.
3. You add the rest that you want, following the template we set up.
--Fred
interface in Perl. He wrote that the Visual Basic and Tcl/Tk data types
are too limiting:
> One of the major reasons Im stopping the work on my VB program is that...
> the underlying data structure is not good. I cannot use the VB Object
> stuff, since my .dll limits me to the 16bit VB, so that forces just
> about everything to be global variables, since procedures can only
> return a single value. I have done some reading on Tcl/tk and find the
> same problems.
> Im very sure that the success of CPNC [Conversational Programming for NC]Could be. The Tcl/Tk GUI for the EMC doesn't require too much in the way
> will depend heavily on the data structure under it. I dont think Tcl will
> give us the structure we need.
of data structures. It uses strings for some of the return values, and
the usual scalar data types (ints, doubles) for the rest. Perl could be
much better:
> I would much prefer to write in Perl/Tk. All the data handing could thenI wrote the Tcl/Tk interface to the EMC. It's C++, in
> be object oriented and much more robust. We could also use the Perl
> module mechanisms to add code. To use a controller like Simple Step or
> FLashCut this would be fine, but to interface to EMC it will be
> necessary to do the same kind of work that was done to tie Tcl to EMC.
> It is not hard, but it does require some C work, and its not something
> Im ready to take on. Who did the emc-tcl work, and can we encourage him
> to do it for Perl?
emc/src/emctask/emcsh.cc, and does the so-called "impedance matching"
that maps strings encountered in a Tcl/Tk script (e.g., "emc_estop on")
to some C++ code that composes and writes the corresponding message to
the EMC command buffer. emcsh.cc starts by connecting to the EMC, then
calls a C++ function in the Tcl/Tk library that enters a main loop that
prints a prompt, reads input, parses it, and interprets it according to
the Tcl/Tk syntax and whatever you added to it in string-function pairs.
Something equivalent can be done in Perl. I have never done this, but I
see from the O'Reilly Perl book, 2nd Edition, on page 371 that there are
references to man pages for perlxstut, perlxs, perlguts, and perlcall
that describe this. XS is a preprocessor that spits out the glue
routines that tie C++ into Perl.
Rather than waiting for me to never get around to it, this could be a
plan for Perl-ifying the EMC:
1. Someone with Perl experience extends Perl with a C++ function that
just increments its argument, e.g.,
int myfunc(int arg)
{
return arg + 1;
}
and then does the gluing to the string "myfunc" so if you do this in a
Perl script:
print myfunc(2)
it prints 3. Forgive my Perl syntax.
2. Once this is done, get it to the emc@... list with notes on what
you did, and we'll clone the glue code to handle comm channels, etc. and
populate it with a representative set of EMC functions.
3. You add the rest that you want, following the template we set up.
--Fred
Discussion Thread
Fred Proctor
2000-05-09 12:42:09 UTC
Conversational programming in Perl for EMC
Matt Shaver
2000-05-09 21:47:21 UTC
Re: Conversational programming in Perl for EMC
Ron Ginger
2000-05-10 11:06:09 UTC
Re: Conversational programming in Perl for EMC