I have a GUI I made with Perl/TK ( http://www.lightandmatter.com/ogr/ogr.html ). I would like to add some hooks so that users can define certain custom computations that they want to happen in certain situations. These are basically going to be simple arithmetic operations, e.g., the one I need for my own use right now is that in a certain place, I need a number to get divided by 10. I was thinking that rather than having users modify the perl code themselves, or hot-plug perl code for this purpose, it might be more reasonable to use an extension language such as Scheme, Lua, or JS. Can anyone suggest how to do this?

The method that occurs to me is to shell out to an interpreter that reads the function's input from stdin and writes the output to stdout. This is probably the most ridiculously inefficient method ever devised to divide a variable by 10, but in my actual use case the performance hit might be undetectable to the person (me) using the GUI. Shelling out is not a security problem because this is a client-side GUI app, not a web app. But is there a nicer way to do this?

I'm not sure what language is most appropriate. Realistically I think I'm the only person who will probably ever use this functionality, and I think it would be fun to play with a lisp. But if someone else was going to use it, they might appreciate a langauge with infix notation such as Lua or JS.

I would like to avoid adding any dependency that isn't available as a debian package, so I guess that leaves out . I definitely don't want to have to build a custom perl interpreter with a Guile library linked in.

After I wrote this, further googling turned up Inline::Guile, but there are indications that it might not actually work -- I'll have to test it. Found this thread: Is there a way to call lisp from perl?, but I'm not seeing anything in there that immediately seems to meet my criteria.

Thanks in advance for any suggestions!


In reply to Extending a perl program with Scheme, Lua, or JS by bcrowell2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.