Ryan Voots wrote:
> I've been wanting to use frink for doing calculations internally in a
> program and I'm wondering if there is a supported way to do this? (its
> for an IRC bot).
Yes, there is a way to embed Frink into a Java program. The section
of the documentation entitled "Embedding Frink" is a good place to start:
http://futureboy.us/frinkdocs/#EmbeddingFrink
By the way, I've already built my own Frink IRC bot; it listens for
calculation requests and returns the answers. It's built around the
PIRCbot framework, which is excellent, but I haven't bothered to add a
lot of features to it. If you're interested in the code, let me know
and I'll clean it up a bit and make it available.
One thing you should consider when making a Frink bot is that Frink
is a Turing-complete programming language. A Frink interpreter normally
has the ability to read your filesystem, call arbitrary Java code,
execute infinite loops, allocate infinite amounts of memory, write
programs that cause your bot to produce lots of output and get itself
banned from IRC channels for "flooding", and do other things which may
compromise your security. (By the way, this is not a problem unique to
Frink; even your web browser has these issues. It's trivial to write
JavaScript that performs infinite loops, allocates more memory than you
have, opens tons of windows, etc.) That's why Frink has its own
security manager framework, which prevents insecure operations from
being performed on your system, but you have to enable that security
manager, which is not well-documented. I'll have to improve that.
Think about: what if someone executes:
read["file:///etc/passwd"]
Having a good security manager is the reason that I can allow people
to type in arbitrary Frink programs in my web interface and execute them
on my computer.
I'll write more about this later if there's interest.
--
Alan Eliasen | "Furious activity is no substitute
eliasen@... | for understanding."
http://futureboy.us/ | --H.H. Williams