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

2004-12-03 Thread Juerd
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


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

2004-12-03 Thread John Siracusa
On Fri, 3 Dec 2004 20:37:40 +0100, Juerd [EMAIL PROTECTED] 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




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

2004-12-03 Thread Juerd
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


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

2004-12-03 Thread Juerd
Juerd skribis 2004-12-03 21:09 (+0100):
 $foo.bar .= foo

Meant ~= there.


Juerd


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

2004-12-03 Thread John Siracusa
On Fri, 3 Dec 2004 22:06:43 +0100, Paul Johnson [EMAIL PROTECTED] 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




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

2004-12-03 Thread Larry Wall
On Fri, Dec 03, 2004 at 04:13:01PM -0500, John Siracusa wrote:
: On Fri, 3 Dec 2004 22:06:43 +0100, Paul Johnson [EMAIL PROTECTED] 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... :)

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


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

2004-12-03 Thread Luke Palmer
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


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

2004-12-03 Thread Paul Johnson
On Fri, Dec 03, 2004 at 02:05:16PM -0500, John Siracusa wrote:

 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.

http://www.nntp.perl.org/group/perl.perl6.language/9576

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net


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

2004-12-03 Thread Mark J. Reed
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  | [EMAIL PROTECTED]
Atlanta, GA 30348  USA   | +1 404 827 4754