'We already have a sub keyword'
David Whipp wrote: Mark J. Reed wrote: Okay, but now we're getting into the fundamental O-O model for Perl. I guess that's fair game? You can certainly make the case that prototype-based inheritance makes at least as much sense as class-based inheritance for a dynamic language like Perl. But that's a major implementation change and you have to be careful to be sure that Perl stays Perl. [...] You could go the Python/JavaScript route and have methods just be members that happen to contain code references, so $obj.meth(@args) would be a synonym for $obj.{meth}.(@args) (or $obj{meth}(@args) with the optional '.'s elided). But then you're merging two namespaces that used to be distinct; e.g. how do you provide an accessor function with the same name as the scalar attribute it's protecting? While I'm also fond of prototype-based inheritance, I think changing the inhertiance model in Perl would be among the most radical changes discussed so far. Not to say it's not doable, but I'm wondering if it would be worth it or if it would really maintain the language's fundamentally Perlish nature. Good, this thread's found a much more productive path. For the distinction between methods vs members, I don't think we have to stray too far from perl-is-perl. Afterall, we already know that foo is a function and $foo is a scalar. So from an implementation perspective there's no problem giving methods and members a separate namespace. Its just a syntax issue ;-). David Whipp intoned, most echoey: We already have a sub keyword; and one of its parameters is the name of the function. Yet when used to define a named function, sub does not appear to return anything. $Ref_to_foo = sub foo($$){print $_[0] was followed by $_[1]\n}; does not work, it must be written $Ref_to_foo = *foo = sub ($$){print $_[0] was followed by $_[1]\n}; Yet another minor candidate for regularization. -- David Nicol 816.235.1187 ftp://ftp.microsoft.com/developr/interix/gpl.txt
Re: 'We already have a sub keyword'
David L. Nicol wrote: Yet another minor candidate for regularization. (Hush, David, Don't say that. Perl should stay Perl! ;-) -- John Porter
Re: 'We already have a sub keyword'
On Wed, Jun 27, 2001 at 05:30:02PM -0400, John Porter wrote: David L. Nicol wrote: Yet another minor candidate for regularization. (Hush, David, Don't say that. Perl should stay Perl! ;-) Okay, I clearly missed out on some heated discussion about the ``Perl bleibt Perl'' RFC. I'll dive into the archives when I have a moment. Meanwhile, I apologize for tripping that particular wire. I agree that there is plenty of room for improvement in Perl; we'd have a lot less to talk about otherwise. All I meant was, as much as I happen to like Python and Ruby and even JavaScript, I have no desire to see Perl turn into a clone of any of them. Re: inheritance. Currently the only thing that gets inherited is methods. If methods are unified with object fields (which is one way to get both prototype and class inheritance), then those would have to be inherited as well. In Perl5 that would be tricky to provide, since there's no consistent representation of objects, or any real concept of an object field. It seems Perl6 will share that agnostic view of objects, but will also provide properties, which would fill the gap nicely if they were inheritable. Maybe inheritable could be a settable property of properties? -- Mark J. REED[EMAIL PROTECTED] -- I have made this letter longer than usual because I lack the time to make it shorter. -- Blaise Pascal