Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Python is not Java...but will Perl 6 be?

21 views
Skip to first unread message

John Siracusa

unread,
Dec 3, 2004, 2:46:16 PM12/3/04
to Perl 6 Language
On Fri, 3 Dec 2004 20:37:40 +0100, Juerd <ju...@convolution.nl> wrote:
> John Siracusa skribis 2004-12-03 14:05 (-0500):
>> From http://dirtsimple.org/2004/12/python-is-not-java.html
>>
>> "In Java, you have to use getters and setters because using public fields
>> gives you no opportunity to go back and change your mind later to using
>> getters and setters. So in Java, you might as well get the chore out of the
>> way up front. In Python, this is silly, because you can start with a normal
>> attribute and change your mind at any time, without affecting any clients of
>> the class. So, don't write getters and setters."
>>
>> I'd like to be able to s/Python/Perl 6/ above, but after many discussions on
>> this topic, I'm still not sure if I can.
>
> Anything can be anything. I'm sure that despite the ability to run all
> the code you want upon reading/writing an attribute, some people will
> still write setters and getters.

I guess I wasn't asking if it would be "possible" (I think that's been
established), but if it would be "easy", "reasonable", or "clean" (as it
appears to be in Python, although I'm just going by what the quoted web page
says). I recall some discussions about the "best" way to this in Perl 6,
but don't recall if it converged on anything nice.

Anyway, I thought it was interesting to see the ease of "forward
compatibility" for simple attributes touted as a feature of Python. I'd
like to tout it as a feature of Perl 6 too, because I also hate writing
getters and setters... :)

-John


Juerd

unread,
Dec 3, 2004, 2:37:40 PM12/3/04
to John Siracusa, perl6-l...@perl.org
John Siracusa skribis 2004-12-03 14:05 (-0500):
> I'd like to be able to s/Python/Perl 6/ above, but after many discussions on
> this topic, I'm still not sure if I can.

Anything can be anything. I'm sure that despite the ability to run all
the code you want upon reading/writing an attribute, some people will
still write setters and getters.

Would it be Perl if it dictated any of these approaches?


Juerd

John Siracusa

unread,
Dec 3, 2004, 2:05:16 PM12/3/04
to Perl 6 Language
From http://dirtsimple.org/2004/12/python-is-not-java.html

"In Java, you have to use getters and setters because using public fields
gives you no opportunity to go back and change your mind later to using
getters and setters. So in Java, you might as well get the chore out of the
way up front. In Python, this is silly, because you can start with a normal
attribute and change your mind at any time, without affecting any clients of
the class. So, don't write getters and setters."

I'd like to be able to s/Python/Perl 6/ above, but after many discussions on


this topic, I'm still not sure if I can.

-John


Juerd

unread,
Dec 3, 2004, 3:09:17 PM12/3/04
to John Siracusa, perl6-l...@perl.org
John Siracusa skribis 2004-12-03 14:46 (-0500):

> Anyway, I thought it was interesting to see the ease of "forward
> compatibility" for simple attributes touted as a feature of Python. I'd
> like to tout it as a feature of Perl 6 too, because I also hate writing
> getters and setters... :)

Of course it's a feature. Having lvalue attributes means you don't have
to replicate all scalar lvalue methods to get all functionality without
copying. IMO, This is even better than in Python, with its constant
variables.

Let me demonstrate:

$foo.bar .= "foo"
$foo.bar ~~ s:e/foo/bar/;
$foo.bar.=reverse;
my $quux := $foo.bar;
$quux = 1;

versus:

$foo.set_bar($foo.get_bar ~ "foo");
$foo.set_bar(do { (my $temp = $foo.get_bar) ~~ s:e/foo/bar/; $temp });
$foo.set_bar($foo.get_bar.reverse);
my $quux # ... ehm, right. Let's see. I think it's something like:
will STORE { $foo.set_bar($_) }
will FETCH { $foo.get_bar };
$quux = 1;


Juerd

Juerd

unread,
Dec 3, 2004, 3:10:33 PM12/3/04
to Juerd, perl6-l...@perl.org
Juerd skribis 2004-12-03 21:09 (+0100):
> $foo.bar .= "foo"

Meant ~= there.


Juerd

John Siracusa

unread,
Dec 3, 2004, 4:13:01 PM12/3/04
to Perl 6 Language
On Fri, 3 Dec 2004 22:06:43 +0100, Paul Johnson <pa...@pjcj.net> wrote:
> http://www.nntp.perl.org/group/perl.perl6.language/9576

Wow, that's a blast from the past. I wonder how much of it is still
valid... :)

-John


Larry Wall

unread,
Dec 3, 2004, 6:14:59 PM12/3/04
to Perl 6 Language
On Fri, Dec 03, 2004 at 04:13:01PM -0500, John Siracusa wrote:

Almost all of it, except for details like "is public". Just because
A12 didn't come out till this year doesn't mean we weren't talking
about those things ever since 2000. I knew that attributes wanted
to look like $.foo since before Apocalypse 1, for instance.

Larry

Luke Palmer

unread,
Dec 3, 2004, 7:41:09 PM12/3/04
to John Siracusa, Perl 6 Language
John Siracusa writes:
> I guess I wasn't asking if it would be "possible" (I think that's been
> established), but if it would be "easy", "reasonable", or "clean" (as
> it appears to be in Python, although I'm just going by what the quoted
> web page says). I recall some discussions about the "best" way to
> this in Perl 6, but don't recall if it converged on anything nice.

It converged on "the core-like way returning an anonymous object with
STORE and FETCH methods is ugly, but it should be easy to provide nice
wrappers around it." Those nice wrappers are probably going to end up
in the standard dialect.

Perl 6 is going to be better with opacity than any other language I know
of. We're aware that lying about what's really going on is a useful
thing to do. So we give you the chance to be as poker-faced about your
internals as you like.

... Not that the user can't read your ass if he tries hard enough :-)

Luke

Paul Johnson

unread,
Dec 3, 2004, 4:06:43 PM12/3/04
to John Siracusa, Perl 6 Language

Mark J. Reed

unread,
Dec 3, 2004, 2:59:25 PM12/3/04
to Perl 6 Language
On 2004-12-03 at 14:46:16, John Siracusa wrote:
> Anyway, I thought it was interesting to see the ease of "forward
> compatibility" for simple attributes touted as a feature of Python. I'd
> like to tout it as a feature of Perl 6 too, because I also hate writing
> getters and setters... :)

Amen.

Which reminds me, what ever happened to POOL? You there, Simon?


--
Mark REED | CNN Internet Technology
1 CNN Center Rm SW0831G | mark...@cnn.com
Atlanta, GA 30348 USA | +1 404 827 4754

0 new messages