Re: RFC - Interpolation of method calls

2000-09-17 Thread Tom Christiansen

Method calls should interpolate in double-quoted strings, and similar
locations.

print "Today's weather will be $weather-temp degrees and sunny.";

Would deparse to:

print 'Today\'s weather will be '.$weather-temp().' degrees and sunny.';


So, the - operator is supposed to get expanded in dq strings, eh?  

What about class methods, like "Give him Employee-salary() again"? 

Or what about things like "move lost-found"?  What does that do?
And why is - special then?  What about "move lost+found"?  Surely
we can't be adding those now!

Isn't it inconsistent to do this?

--tom



Re: RFC - Interpolation of method calls

2000-09-17 Thread Nathan Wiger

Tom Christiansen wrote:
 
 print "Today's weather will be $weather-temp degrees and sunny.";
 
 So, the - operator is supposed to get expanded in dq strings, eh?

It already does, or at least appears to to users:

print "Today's weather will be $weather-{temp} degrees and sunny.";
print "Today's weather will be $weather-[0] degrees and sunny.";
 
 Isn't it inconsistent to do this?

I think it's far more inconsistent to have the above work but not have
methods interpolate. And yes, I realize they're different thingies but
they're very close syntactically and cognitively, especially for data
access (which is really what we're talking about here).

I've always found it quite surprising and cumbersome to have to do this:

print "Today's weather will be ", $weather-temp, " degrees and
sunny.";

When the above two work fine.

-Nate



Re: RFC - Interpolation of method calls

2000-09-17 Thread Michael G Schwern

Sorry, I wasn't subscribed to perl6-language-objects and didn't even
realize there was a discussion going on.  I just fixed that.

I didn't mean to hijack RFC 103, I can't remember if I'd even looked
at it before... but Nathan seems okay with that and it is a
deceptively large issue.

Version 2 of the RFC went out last night (I'll have to do v3 after
reading these comments) and clarifies a few things (the changes are
all listed at the top).  Most importantly, C"$weather-temp("F")"
was a typo.  It should have been C"$weather-temp(\"F\")".  Also,
RFCs about interpolation of class methods and subroutines also went
out last night, so I'll let them speak for themselves.


Now, about that context thing.  The main conundrum is what to do with
methods that return a list.  Would it be best to just let it be scalar
context?

# $inventory-pinatas returns a list of pinatas we have.
# "Yes, El Guapo, I would say I have 23 pinatas\n";
print "Yes, El Guapo, I would say I have $inventory-pinatas pinatas\n";

Or would it be better to expand the returned list, as arrays are
expanded with Cjoin $", @array?  Now that I think about it, its
fairly obvious that simple scalar context is best.  Why?  I can't even
think of a useful example of the list expansion.

Most of the time you want to seperate them with a ", " anyway, not
with $".

So junk that bit about the context weirdness.  Simple scalar context it is.


Nathan already covered the questions about evaluating expressions and
arguments.  Perl already does it for everything else.  Furthermore,
interpolating the expression should be simple, as I realized later
while writing the RFC for interpolatoin of subroutines.

  The tokenizer can watch for /[A-Z_]\w*/i.  If followed by a '(', then the
  parsing becomes the same as for normal subroutine arguments excepting that 
  it must watch for an unescaped closing string character.


I'm also glad to find out Perl already disallows whitespace for other
interpolated constructs.


I appear to have a new version of the RFC ready without the first even
having made it out to the public!


-- 

Michael G Schwern  http://www.pobox.com/~schwern/  [EMAIL PROTECTED]
Just Another Stupid Consultant  Perl6 Kwalitee Ashuranse
Many people think that an UFO is probably propelled by some kind of
antigravity magnetic motor. I have a totally different thinking. I believe
that an UFO is propelled by jet engine. UFO's gyroscopic body rotates and
serves as its wing to keep UFO's body balanced in the air.
 --Alex Chiu, Immortality Guy



Re: RFC - Interpolation of method calls

2000-09-17 Thread Michael G Schwern

On Sun, Sep 17, 2000 at 08:56:23PM -0600, Tom Christiansen wrote:
 While you're there, you should fix it to spell piƱatas properly. :-(
 We're not talking about stands of pine trees, presumably.

Funny, I know how to type extended characters in MacOS, but I have no
idea how to do it in X.  Hell, my font doesn't even display them right.
*grumble*

-- 

Michael G Schwern  http://www.pobox.com/~schwern/  [EMAIL PROTECTED]
Just Another Stupid Consultant  Perl6 Kwalitee Ashuranse
BOFH excuse #270:

Someone has messed up the kernel pointers



Re: RFC 163 (v2) Objects: Autoaccessors for object data structures

2000-09-17 Thread Matthew Cline

On Sun, 17 Sep 2000, Perl6 RFC Librarian wrote:


 This example shows how much easier it would have been to write the
 example on line 170 of perltoot.pod:

 package Person;
 use strict;

 ##
 ## the object constructor (simplistic version)  ##
 ##
 sub new {
 my $self  = {};
 $self-{name}  :laccess :raccess = undef;
 $self-{age}   :laccess :raccess = undef;
 $self-{peers} :laccess :raccess = [];
 return bless $self;
 }

Would these attributes carry if you copied the whole array?  For that matter, 
can you even copy an object an automagically copy the blessing as well?  
Urgh.  I don't know enough about perl to know if this is doable, or even 
desireable.  But something like this might be nice:


 package Person;
 use strict;

 # Construct an archtype to make copies of when
 # new is invoked
 my $archtype  = {};
 $archtype-{name}  :laccess :raccess = undef;
 $archtype{age}   :laccess :raccess = undef;
 $archtype-{peers} :laccess :raccess = [];
 bless $archtype;

 ##
 ## the object constructor (simplistic version)  ##
 ##
 sub new {
 return copy_of($archtype);
 }

Hmmm.  If this is desireable, but not doable, I suppose it would take another 
RFC.