Perl
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists Perl

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old July 4th, 2008, 06:20 AM
Gabor Szabo
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
strictly no indirect object syntax?

Do I understand correctly that you would like to disallow
the following syntax as well?

my $obj = new Car;


If so, can we start by removing it from the documentation in core?

Gabor

Reply With Quote
  #2  
Old July 4th, 2008, 09:01 AM
Nicholas Clark
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
strictly no indirect object syntax?

Fri, Jul 04, 2008 at 12:05:12PM +0300, Gabor Szabo wrote:
Do I understand correctly that you would like to disallow
the following syntax as well?

my $obj = new Car;

As an option, yes.

If so, can we start by removing it from the documentation in core?

I thought that chromatic had been busy not that long ago sending patches to
remove it. There are still places left?

Nicholas Clark

Reply With Quote
  #3  
Old July 4th, 2008, 12:01 PM
Jan Dubois
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
strictly no indirect object syntax?

Fri, 04 Jul 2008, Gabor Szabo wrote:
Do I understand correctly that you would like to disallow the
following syntax as well?
>

my $obj = new Car;

Yes, that is indirect object syntax. It means

my $obj = Car::->new();

if neither a new() nor a Car() method have been defined (or imported)
in the current package. If new() is defined, then it means either

my $obj = new(Car());

if Car() is defined too, or

my $obj = new("Car");

if it isn't. The latter case would also generate a bareword warning
if enabled.

While not indirect object syntax, I wonder if we shouldn't also do
something about "Car::->new" vs. "Car->new". The latter actually
means Car()->new when Car() is defined in the current namespace,
so it has a similar gotcha as indirect object syntax:

sub Foo::method { print "Foo method\n" }
sub Bar::method { print "Bar method\n" }

sub Foo { return bless [] ="Bar" }

Foo->method; # Prints "Bar method"
Foo::->method; # Prints "Foo method"
Foo()->method; # Prints "Bar method"

I think the "Foo->method" call should generate a warning that it is
being resolved as "Foo()->method", just like

use warnings;
sub die {print "my die\n"}
die;

warns with

Ambiguous call resolved as CRE::die(), qualify as such or use &

Cheers,
-Jan

Reply With Quote
  #4  
Old July 4th, 2008, 12:40 PM
Jan Dubois
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
strictly no indirect object syntax?

Fri, 04 Jul 2008, Eric Wilhelm wrote:

# from Jan Dubois
# on Friday 04 July 2008 08:50:

>* Foo->method; * * # Prints "Bar method"
>* Foo::->method; * # Prints "Foo method"
>* Foo()->method; * # Prints "Bar method"
>
>I think the "Foo->method" call should generate a warning that it is
>being resolved as "Foo()->method", just like


If so, how would you disable it on a per-bareword basis so that
aliased.pm still works?

sub Foo () :alias {'Bar'}

Note that this should only warn if %bar:: isn't empty (at compiletime),
because otherwise it isn't ambiguous.

If you do have a regular %Bar:: namespace *and* want to alias another
package name to 'Bar', then you can always disable the warnings with

no warnings 'ambiguous';

just the same way you can disable the current warnings about resolving
ambiguous function calls to their CRE:: version can be suppressed.

Cheers,
-Jan

Reply With Quote
  #5  
Old July 4th, 2008, 05:20 PM
chromatic
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
strictly no indirect object syntax?

Friday 04 July 2008 06:56:54 Nicholas Clark wrote:

Fri, Jul 04, 2008 at 12:05:12PM +0300, Gabor Szabo wrote:
Do I understand correctly that you would like to disallow
the following syntax as well?
>

my $obj = new Car;
>

As an option, yes.
>

If so, can we start by removing it from the documentation in core?
>

I thought that chromatic had been busy not that long ago sending patches to
remove it. There are still places left?

At least one author of a dual-lived module objected, and I gave up.

-- c

Reply With Quote
  #6  
Old July 4th, 2008, 06:40 PM
Abigail
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
strictly no indirect object syntax?

Fri, Jul 04, 2008 at 08:50:00AM -0700, Jan Dubois wrote:

While not indirect object syntax, I wonder if we shouldn't also do
something about "Car::->new" vs. "Car->new". The latter actually
means Car()->new when Car() is defined in the current namespace,
so it has a similar gotcha as indirect object syntax:

sub Foo::method { print "Foo method\n" }
sub Bar::method { print "Bar method\n" }

sub Foo { return bless [] ="Bar" }

Foo->method; # Prints "Bar method"
Foo::->method; # Prints "Foo method"
Foo()->method; # Prints "Bar method"

Yes, but the commonly followed standard is that subroutine names are
in all lowercase. While I agree that in theory the gotcha is similar,
in practise, it will be far less of an issue.

I think the "Foo->method" call should generate a warning that it is
being resolved as "Foo()->method", just like

Well, only if it *is* resolved to "Foo()->method", that is, only warn
if there's an actual Foo() subroutine that will be called.
the warning will trigger too many false positives to be of any use.



Abigail

Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists Perl > strictly no indirect object syntax?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT