Re: Idea: Can we modify Devel::REPL or combine with Perl Object Environment to have programmatic interaction with a gtk2-perl process like in other languages?



On 22:09 Sun 19 Apr     , Sergei Steshenko wrote:


Well, I do not know Python except for vewry basic/primitive stuff.

However, Perl is a "strategically" different from Python language, i.e. it
has fundamental features Python doesn't have or has them in a very
rudimentary form.

I think you misunderstood. I like perl and would like to have an interactive perl shell for gtk2-perl


The features are:

* closures;
* lexical scoping;
* anonimyty.

I am familiar with perl :).


I.e. its functional features.

So, to add something to a running Perl program is different from the same
in Python.

For example, the following (AFAIK) cannot be translated into Python without
adding extra names:

I know about closures. I use perl.
I am not interested in  perl vs python advocacy. 
We can pick features from other languages and see if we can have them too.
The more we know from other cultures, the more we can develop new ideas in our own.
See the well written article at the Perl.com site: 
Mark Dominus: "Why I hate advocacy"
http://www.perl.com/pub/a/2000/12/advocacy.html


  { 
  my $parent = $this; 
 
  my $on_text  = "On"; 
  my $off_text = "Off"; 
 
  my $this = Gtk2::ToggleButton->new($off_text); 
 
  $this->signal_connect 
    ( 
    clicked => 
      sub 
        { 
        if($this->get_active) 
          { 
          $this->set_label($on_text); 
          } 
        else 
          { 
          $this->set_label($off_text); 
          } 
 
        # do the real stuff here 
        } # sub 
    ); # $this->signal_connect 
 
  $parent->pack_start($this, FALSE, FALSE, 0); 
 
  $this->show; 
  }
.

Note there is a number of hierarchy levels, and each of them has its own
$this, $parent.

Using lexical scoping you can easily add as many nested levels as you
wish, still just using

  {
  my $parent = $this; # this $this belongs to outer scope
  ...
  my $this = SomeClass->new(...); # this $this belongs to this scope and
                                  # defines a new widget/instance/etc.
  ...
  }

I.e. in Perl it's very easy to add things from inside, and lexical scoping
provided excellent encapsulation/data protection, so it's impossible by
normal means to access inner data from outside.

Adding code from inside is simple - either you just write it, or you
do it this way:

  {
  ... # existing stuff
  do "file_with_new_stuff.pl"; # code in the file is evaluated in the
                               # current scope, so all lexical variable are
                               # accessible
  ... # existing stuff
  }


Sergei, you have pretty code here, I agree, but it doesn't do what I was thinking of...

I would like to play and refactor my code as I work. 
I dont want to have to plan my alternatives in advance.

Take a look at the work done on Devel::REPL and compare it with the perl shells
in 

1) the perl debugger
2) Nice code approaches of muppet and Remco Wouts that he pointed to in his letter.
3) Code base of Devel::REPL and the plug ins there.
4) Stylish::REPL derived from that...

and take a look at this perl code
http://blog.jrock.us/articles/Stylish REPL.pod

and see this amazing video made by Jonathan Rockway:

http://www.iinteractive.com/stylish-repl-screencast.ogv

who has created a full 'Slime like environment' (that is Slime as in common lisp!!!)  to do perl coding from 
emacs
called Stylish!!!


To appreciate the video, you should realize that he is mimicking the famous SBCL-Slime Lisp interaction mode 
- Emacs video by Marco Baringer 
http://www.archive.org/details/UsingtheSLIMELispInteractionModeforEmacs.

It is amazing to do that for perl!

Mitchell



 






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]