zsh-workers
 help / color / mirror / code / Atom feed
* Re: Zsh and Perl?
@ 1999-08-23 11:30 Mike Fletcher
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Fletcher @ 1999-08-23 11:30 UTC (permalink / raw)
  To: zsh-workers


        I've already got a start at a perl interpreter embeded into
zsh as a loadable module.  It's still *really* rough, but so far:

        *) you can do the equivalent of 'use Module' from zsh to load
           perl modules into the interpreter

        *) you can define builtins as perl subroutines 

        *) there's a minimal wrapper for accessing zsh parameters from
           perl code


        If there's any interest, mail me and I'll throw what I've got
up on the web.

        Also, please Cc any follow-ups to me; I'm having problems
getting subscribed to zsh-workers for some reason, which is why I
hadn't spoken up the first time this was mentioned.

-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch@phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
678 443-6239(w)       |  scary questions." -- Jules                =(___)=
                      |                                               U


^ permalink raw reply	[flat|nested] 5+ messages in thread
* Zsh and Perl?
@ 1999-08-04 18:13 Jeff Solomon
  1999-08-04 22:02 ` Bruce Stephens
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jeff Solomon @ 1999-08-04 18:13 UTC (permalink / raw)
  To: zsh-workers, pws


Hi,

I'm very sorry if this question seems naive but I've dug a little
through the zsh source code and it seems appropriate.

I think a common task that many people are faced with is writing
little debugging tools. Frequently, they may write such a tool in a
language like Perl because it's so time efficient. Then they realize
that they have no interface for their tool so they either write their
own or they have none at all or mostly have something just like this:

    while( get_input_line_from_terminal_driver ) {
      process_input_line
    }

This makes the interface really, really bad, but the tool writer wants 
to worry about whatever they are debugging (or whatever) and not the
interface.

I've been doing a few of these tools for our research group and I've
gotten pretty good at using libraries like GNU Readline to spruce up
my interfaces, but I find myself constantly trying to emulate what shells
like Zsh already do and do very well.

I've looked at the source for tcsh, bash and now zsh and zsh *by far*
looks the best written and best suited for this task because it seems
so modular.

So I'm asking the zsh developers about the best way to solve this
problem. Basically I want to either embed perl into zsh or embed zsh
into perl, but the key is that my perl commands have to share state
from one instance of a perl interpreter.

Embed perl into zsh:
    
    Looking at the source, this looks like the most straightforward
    thing to do. It seems easy to add a 'perl_eval' command that would 
    evaluate a snippet of perl in a persistent interpreter. But I
    would want to add command into the zsh enviroment from perl so I
    can type:

	my_command my_arg1 my_arg2

    instead of

	perl_eval 'my_command my_arg1 my_arg2'

    which means you'd have to add support for calling back into zsh
    from perl.

Embed zsh into perl:

    zsh is turned into a loadable perl module and I write a script
    directly using zsh. It might look something like this:

    use Shell::Zsh;

    my $zsh = Shell::Zsh->new;

    $zsh->register_command_callback(\&my_callback);

    $zsh->other_customizations.... (add commands for completion, etc)

    $zsh->mainloop;

    sub my_callback {
       process command
    }
    
Anyway, I've gone on long enough. I'm just looking for feedback on
this general idea. Has anyone done this yet? (searching through the
source for 'perl' doesn't find much, and searching the website for
'perl' never returns). Any ideas on which option would be easier to
implement/use?

Any thoughts would be appreciated.

Jeff


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1999-08-25 11:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-23 11:30 Zsh and Perl? Mike Fletcher
  -- strict thread matches above, loose matches on Subject: below --
1999-08-04 18:13 Jeff Solomon
1999-08-04 22:02 ` Bruce Stephens
1999-08-05  5:39 ` Bart Schaefer
1999-08-05  8:31 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).