Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Zsh and Perl?



On Aug 4, 11:13am, Jeff Solomon wrote:
} Subject: Zsh and Perl?
}
} 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.

You may very well be correct, but I'd like an example of such a tool if
you can share one.  I wouldn't have referred to any of the perl tools I
write as "debugging" tools, but perhaps you're speaking as an admin who
has to debug network connections or protocols, or the like.

I say this because ...

} So I'm asking the zsh developers about the best way to solve this
} problem. Basically I want to [...]

... you seem to have already made up your mind about the best way to solve
the problem, and I want to be convinced that you're right.  Marrying perl
to zsh isn't going to help people who write tools in awk or tcl or python.

For example, have you considered running the debugging tool as a coproc?

Nevertheless, to answer your specific questions ...

} 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 [...]

Zsh 3.1.6 modules are the thing for this.  For one thing, you can load
and unload them dynamically; so you don't have to bloat zsh permanently
with a perl interpreter, and you can force the interpreter to shut down
if necessary -- and with a lot of OOPerl programs, that's required to get
all the object cleanup to happen.

For another thing, as of 3.1.6 loadable modules can export zsh parameters,
so you can theoretically make the perl scalar namespace visible to zsh.
You might even be able to make (copies of) perl arrays visible, and bits
of perl hashes, though zsh doesn't have nested arrays/hashes.

Finally, of course, zsh modules were originally designed to supply new
builtin commands, and you can add as many as you like from each module.

} Embed zsh into perl:
} 
}     zsh is turned into a loadable perl module and I write a script
}     directly using zsh.

That would be a major engineering effort.  Perl has already gone through
the necessary transformations to become a linkable interpreter "library"; 
zsh has not, and I suspect it would be an ugly task to do so.

} Has anyone done this yet?

It's been mentioned a number of times, but nobody has ever been motivated
enough to go through with it.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author