Support for interactive interpreters...

2001-01-17 Thread Branden

Hi.

I'm actually not following this list from close and I searching the archives
isn't that easy yet, so pardon me if this was already brought up.

I work with Perl and I also work with Tcl, and one thing I actually like
about Tcl is that it's interactive like a shell, i.e. it gives you a prompt,
where you type commands in and, if you type a whole command by the end of
the line, it executes it, otherwise, it gives you another prompt and keeps
reading more lines until the whole command is typed, when it's executed. I
think this is particularly useful for:
a) testing features (what the value of ... would be if I ...?)
b) debugging (what is the value of the variable ...?/what would the function
... return if I give it value ...?) and building custom debuggers
c) learning modules' interfaces
d) making changes at runtime (I will change the value of this variable
now...)

I understand the Perl 5's debugger can handle some of these tasks, but I
argue that its support is quite incomplete, it's hard to do if's or while
loops, and it's very hard (I would say impossible) to customize the debugger
for some of the uses above.

Tcl manages this by having a function that gets a line of command and
returns wheter it's complete, or another line should be read to try to
complete it. Of course Tcl can do it because it's much simpler than Perl in
its syntax, having this done in Perl is a much more complex subject.

Still, I think it's worth it. And now is for sure the time to think on this
kind of thing. After the implementation is done, if it's there, it's there,
otherwise, it will probably never be!

Thanks a lot.

Branden




Re: Support for interactive interpreters...

2001-01-17 Thread Simon Cozens

On Wed, Jan 17, 2001 at 11:03:05AM -0200, Branden wrote:
> I work with Perl and I also work with Tcl, and one thing I actually like
> about Tcl is that it's interactive like a shell, i.e. it gives you a prompt,
> where you type commands in and, if you type a whole command by the end of
> the line, it executes it, otherwise, it gives you another prompt and keeps
> reading more lines until the whole command is typed, when it's executed.

Sounds like http://dev.perl.org/rfc/184.html to me.

-- 
Do not go gentle into that good night/Rage, rage against the dying of the light



Re: Support for interactive interpreters...

2001-01-17 Thread Tim Jenness

On Wed, 17 Jan 2001, Branden wrote:

> I'm actually not following this list from close and I searching the archives
> isn't that easy yet, so pardon me if this was already brought up.
>
> I work with Perl and I also work with Tcl, and one thing I actually like
> about Tcl is that it's interactive like a shell, i.e. it gives you a prompt,
> where you type commands in and, if you type a whole command by the end of
> the line, it executes it, otherwise, it gives you another prompt and keeps
> reading more lines until the whole command is typed, when it's executed. I
> think this is particularly useful for:
> a) testing features (what the value of ... would be if I ...?)

This may not sound obvious but I use the Perl Data Language (PDL) for
interactive testing since it provides a shell interface. It's not perfect
(needs to be extended to handle multi-line input) but it's a start.

Both Python and Tcl support features like this and I agree that a perl
shell would be useful.

-- 
Tim Jenness
JCMT software engineer/Support scientist
http://www.jach.hawaii.edu/~timj





Re: Support for interactive interpreters...

2001-01-17 Thread Dan Sugalski

At 11:03 AM 1/17/01 -0200, Branden wrote:
>Hi.
>
>I'm actually not following this list from close and I searching the archives
>isn't that easy yet, so pardon me if this was already brought up.

As Simon's pointed out, there's an RFC for this already.

It's actually not that tough to do now with eval, with two problems:

*) Eval won't extend scope, so each statement you execute stands alone. (So 
lexicals go missing immediately)
*) Figuring out where a statement ends is a pain--you'd want to read to the 
end of a block for example before executing it.

I'd personally like to provide a scopeless string eval, and the second 
issue's a SMOP. (Though involving the parser on the fly would make it easier)

Dan

--"it's like this"---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
  teddy bears get drunk