Perl 6 and OOP

Discussion in 'Perl Misc' started by J. Romano, Sep 10, 2004.

  1. J. Romano

    J. Romano Guest

    Greetings!

    After doing some work with Object-Oriented Perl (and helping a
    friend learn it, as well), we both agree that the Data::Dumper module
    is a valuable tool for debugging OO Perl programs, as it lets us
    easily see the structure and contents of complex objects (which is
    something I wish more OO languages had readily available).

    Now, OO Perl has had its critics, most of which are quick to say
    that OO Perl is messy and doesn't enforce private data very well.
    However, some do admit that this makes OO Perl quite flexible -- for
    instance, a Perl object can be easily examined with the Data::Dumper
    module as a result of its laid-back policy on information hiding.

    Now to my question: Knowing that Perl 6 will have better OO
    handling, does that mean that Data::Dumper will lose its usefulness on
    Perl 6 objects? Or will it still be able to let a programmer peer
    into them and let him/her tinker with their data using the debugger?

    I'm hoping for the latter case, even though that case is sure not
    to eliminate all of Perl's OO criticisms that gripe about the lack of
    information hiding.

    -- Jean-Luc
     
    J. Romano, Sep 10, 2004
    #1
    1. Advertising

  2. J. Romano

    Uri Guttman Guest

    >>>>> "JR" == J Romano <> writes:

    JR> Now to my question: Knowing that Perl 6 will have better OO
    JR> handling, does that mean that Data::Dumper will lose its usefulness on
    JR> Perl 6 objects? Or will it still be able to let a programmer peer
    JR> into them and let him/her tinker with their data using the debugger?


    you seem to be conflating data::dumper and OO. dumper is not an OO tool
    but a debugging and data tool. i have (as have many others) used it in
    many non-oo programs. it is just a way to dump perl data structures (oo
    or not) in a way that can be evaled and also read by hyoomans.

    JR> I'm hoping for the latter case, even though that case is sure not
    JR> to eliminate all of Perl's OO criticisms that gripe about the lack of
    JR> information hiding.

    i am not sure what you are talking about. dumper as it is won't do that
    in perl6. but there are ways to introspect anything in perl6 (normal
    code won't be able to accidentally do that) so dumper can be modified to
    do that. i am sure the p6/parrot teams will make sure of that since
    dumper is such a useful tool regardless of the OO nature of the data.

    uri

    --
    Uri Guttman ------ -------- http://www.stemsystems.com
    --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
    Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
     
    Uri Guttman, Sep 10, 2004
    #2
    1. Advertising

  3. Uri Guttman wrote:
    >
    > you seem to be conflating data::dumper and OO. dumper is not an OO tool

    ^^^^^^^^^^^^

    Time soon to ask somebody to fix that broken shift key? After all,
    module names are case sensitive. ;-)

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Sep 10, 2004
    #3
  4. On 10 Sep 2004 07:04:12 -0700, (J. Romano) wrote:

    > Now to my question: Knowing that Perl 6 will have better OO
    >handling, does that mean that Data::Dumper will lose its usefulness on
    >Perl 6 objects? Or will it still be able to let a programmer peer
    >into them and let him/her tinker with their data using the debugger?


    There will be a predefined method for this. Only, the definitive name
    has not been chosen yet. Proposals include, not surprisingly C<.code>,
    C<.dump>, etc. Larry has been thinking about C<.perl>, envisioning a
    possible future for, say, C<.python>, C<.ruby>, etc.


    Michele
    --
    {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
    (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
    ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
    256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
     
    Michele Dondi, Sep 10, 2004
    #4
  5. J. Romano

    J. Romano Guest

    > On 10 Sep 2004 07:04:12 -0700, (J. Romano) wrote:
    >
    > > Now to my question: Knowing that Perl 6 will have better OO
    > >handling, does that mean that Data::Dumper will lose its usefulness on
    > >Perl 6 objects? Or will it still be able to let a programmer peer
    > >into them and let him/her tinker with their data using the debugger?


    Michele Dondi <> replied in message
    news:<>...
    >
    > There will be a predefined method for this. Only, the definitive name
    > has not been chosen yet. Proposals include, not surprisingly C<.code>,
    > C<.dump>, etc. Larry has been thinking about C<.perl>, envisioning a
    > possible future for, say, C<.python>, C<.ruby>, etc.


    Interesting.

    But I'm confused as to what the .perl() method would do. Are you
    saying that "$a.perl()" would do the same thing that "Dumper $a" does
    now? And if that's so, what would "$a.python()" and "$a.ruby()"
    generate? (Code that can be eval()'ed in those respective languages,
    maybe? That would be very interesting, I would think. Molto
    interessante...)

    -- Jean-Luc
     
    J. Romano, Sep 11, 2004
    #5
  6. On 10 Sep 2004 22:41:53 -0700, (J. Romano) wrote:

    > But I'm confused as to what the .perl() method would do. Are you
    >saying that "$a.perl()" would do the same thing that "Dumper $a" does


    Yes, it will yield a stringified perl representation of its object.

    >now? And if that's so, what would "$a.python()" and "$a.ruby()"
    >generate? (Code that can be eval()'ed in those respective languages,
    >maybe? That would be very interesting, I would think. Molto
    >interessante...)


    Yes, *if* python and ruby *do* support such a thing, I'd say.
    (Disclaimer: as you may have already understood, I don't know anything
    about these two languages). Anyway (i) they're both being retargeted,
    along with Perl, to the parrot runtime[*], AIUI, (ii) ... Larry said
    it!


    [*] And I *guess* this will greatly improve cross-language
    compatibility.


    Michele
    --
    {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
    (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
    ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
    256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
     
    Michele Dondi, Sep 11, 2004
    #6
  7. J. Romano

    J. Romano Guest

    > >>>>> "JR" == J Romano <> writes:
    >
    > JR> Now to my question: Knowing that Perl 6 will have better OO
    > JR> handling, does that mean that Data::Dumper will lose its usefulness on
    > JR> Perl 6 objects? Or will it still be able to let a programmer peer
    > JR> into them and let him/her tinker with their data using the debugger?


    Uri Guttman <> replied in message
    news:<>...
    >
    > you seem to be conflating data::dumper and OO. dumper is not an OO tool
    > but a debugging and data tool. i have (as have many others) used it in
    > many non-oo programs. it is just a way to dump perl data structures (oo
    > or not) in a way that can be evaled and also read by hyoomans.


    Oh, I agree with you there. When I first found out about the
    Data::Dumper module I used it all the time to look at the structures
    of complex arrays and hashes. But eventually I found out that it also
    works amazingly well with blessed objects.

    Now I use it whenever I work with Perl objects, whether I wrote
    them or not. Debugging OO code is so much easier with Data::Dumper
    since I don't have to guess about a blessed object's current structure
    based on the code that may or may not have been executed.
    Data::Dumper may break the idea of Object-Oriented Information Hiding,
    but it's been a wonderful tool for me to use when I venture into the
    OO world.

    What I'm trying to say is that the Data::Dumper module was so
    well-thought out (in my opinion) that it works just as well with Perl
    objects as with non-objects. There is no additional tweaking
    necessary on my part to get Data::Dumper to work on a reference just
    because it is blessed. The module knows about blessed references and
    is able to create an appropriate string to eval() without ever having
    me worry about it.

    -- Jean-Luc
     
    J. Romano, Sep 11, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Leslie Viljoen

    Easy OOP with Perl

    Leslie Viljoen, Feb 21, 2005, in forum: Perl
    Replies:
    0
    Views:
    526
    Leslie Viljoen
    Feb 21, 2005
  2. kj
    Replies:
    3
    Views:
    115
    James Willmore
    May 14, 2004
  3. Veli-Pekka Tätilä
    Replies:
    7
    Views:
    165
    Veli-Pekka Tätilä
    Aug 20, 2005
  4. Peter Michaux

    New to Perl, OOP inheritance

    Peter Michaux, Feb 16, 2007, in forum: Perl Misc
    Replies:
    4
    Views:
    107
    Peter Michaux
    Feb 17, 2007
  5. Nene
    Replies:
    3
    Views:
    379
Loading...

Share This Page