develooper Front page | perl.perl6.language | Postings from April 2001

Dot can DWIM without whitespace

Thread Next
From:
Brent Dax
Date:
April 24, 2001 19:37
Subject:
Dot can DWIM without whitespace
Message ID:
HBEGLJIBLLACNDGOHOKMKENBCBAA.brentdax1@earthlink.net
IMHO, . can DWIM in most cases even if it's both object deref _and_
concat--without paying any attention to whitespace.

Let's think about this for a minute.  What are the common cases for use of
concat?

$a."b";
"a".$b;
$a.$b;
a.$b;
$a.b;
a.b;

The first two are obviously concat, since that code makes absolutely no
sense as an object deref.  Unless we decide that objects can contain scalars
and to access them you must prefix their name with $, the middle pair can't
be object calls, so they're concat.  The last two, however, are ambiguous.
How can we figure out what they mean?

Two possibilities:
1) we define a cc (or something like that--I prefer j, since it's shorter)
operator that _always_ means concat, or
2) when you mean "call a function called b", you have to say &b;

Alternately, we can overload . to do a deref on (blessed?) references, and
concat otherwise.

Does any of that make sense?  Or should I be returned to my straightjacket?
:^)

--Brent Dax
brentdax1@earthlink.net


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About