summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1997-01-01 08:59:00 +1200
committerChip Salzenberg <chip@atlantic.net>1997-01-01 08:59:00 +1200
commita60067777be62ee91d1318f9ae26d9ed713245de (patch)
tree9e312a824c6ef40aa10dd0e60451fd737098a965 /lib
parenta034a98d8bfd0fd904012bd5227ce209aaaa0b26 (diff)
downloadperl-a60067777be62ee91d1318f9ae26d9ed713245de.tar.gz
[inseparable changes from patch from perl5.003_17 to perl5.003_18]
CORE LANGUAGE CHANGES Subject: Inherited overloading Date: Sun, 29 Dec 1996 08:12:54 -0500 (EST) From: Ilya Zakharevich <ilya@math.ohio-state.edu> Files: gv.c lib/overload.pm perl.h sv.c sv.h t/op/overload.t Chip Salzenberg writes: > > Patch now, tarchive later: Below is the fixed overloading patch. Note that in between AMG_names got const on it (a good thing!), but as a corollary I needed to cast away const-ness to actually use it (since, say, newSVpv does not have const args). Enjoy, p5p-msgid: <199612291312.IAA02134@monk.mps.ohio-state.edu> Subject: Closures at file scope must be anonymous From: Chip Salzenberg <chip@atlantic.net> Files: op.c Subject: Warn on '{if,while} ($x = X)' where X is glob, readdir, or <FH> From: Chip Salzenberg <chip@atlantic.net> Files: op.c pod/perldiag.pod DOCUMENTATION Subject: Re: perldiag.pod entry for "Scalar value @%s{%s} ..." Date: Tue, 31 Dec 1996 11:50:19 -0500 From: Roderick Schertler <roderick@gate.net> Files: pod/perldiag.pod Msg-ID: <2043.852051019@eeyore.ibcinc.com> (applied based on p5p patch as commit c885792efecf3f527b3b5099727cc16b03eee1dc) OTHER CORE CHANGES Subject: Get rid of 'Leaked scalars' From: Chip Salzenberg <chip@atlantic.net> Files: cop.h gv.c op.c TESTS Subject: Expanded locale.t and misc.t From: Jarkko Hietaniemi <jhi@cc.hut.fi> Files: t/lib/locale.t t/lib/misc.t Subject: Expanded my.t From: Chip Salzenberg <chip@atlantic.net> Files: t/lib/my.t
Diffstat (limited to 'lib')
-rw-r--r--lib/Class/Template.pm2
-rw-r--r--lib/ExtUtils/Embed.pm8
-rw-r--r--lib/FileHandle.pm2
-rw-r--r--lib/Net/netent.pm4
-rw-r--r--lib/Tie/Hash.pm2
-rwxr-xr-xlib/diagnostics.pm4
-rw-r--r--lib/overload.pm62
7 files changed, 54 insertions, 30 deletions
diff --git a/lib/Class/Template.pm b/lib/Class/Template.pm
index 311c72ae5e..23a0d5ba83 100644
--- a/lib/Class/Template.pm
+++ b/lib/Class/Template.pm
@@ -84,7 +84,7 @@ This module uses perl5 classes to create nested data types.
}
=head1 NOTES
-
+
Use '%' if the member should point to an anonymous hash. Use '@' if the
member should point to an anonymous array.
diff --git a/lib/ExtUtils/Embed.pm b/lib/ExtUtils/Embed.pm
index fb2664c86f..c663d64dd7 100644
--- a/lib/ExtUtils/Embed.pm
+++ b/lib/ExtUtils/Embed.pm
@@ -265,7 +265,7 @@ functions while building your application.
=head1 @EXPORT
ExtUtils::Embed exports the following functions:
-
+
xsinit(), ldopts(), ccopts(), perl_inc(), ccflags(),
ccdlflags(), xsi_header(), xsi_protos(), xsi_body()
@@ -301,7 +301,7 @@ B<[@modules]> is an array ref, same as additional arguments mentioned above.
=item Examples
-
+
perl -MExtUtils::Embed -e xsinit -- -o xsinit.c Socket
@@ -395,7 +395,7 @@ are picked up from the B<extralibs.ld> file in the same directory.
perl -MExtUtils::Embed -e ldopts -- -std Socket
-
+
This will do the same as the above example, along with printing additional arguments for linking with the B<Socket> extension.
@@ -457,7 +457,7 @@ B<xsinit()> uses the xsi_* functions to generate most of it's code.
For examples on how to use B<ExtUtils::Embed> for building C/C++ applications
with embedded perl, see the eg/ directory and L<perlembed>.
-
+
=head1 SEE ALSO
L<perlembed>
diff --git a/lib/FileHandle.pm b/lib/FileHandle.pm
index e2ce83d44a..aa8282b68d 100644
--- a/lib/FileHandle.pm
+++ b/lib/FileHandle.pm
@@ -184,7 +184,7 @@ result!
See L<perlfunc> for complete descriptions of each of the following
supported C<FileHandle> methods, which are just front ends for the
corresponding built-in functions:
-
+
close
fileno
getc
diff --git a/lib/Net/netent.pm b/lib/Net/netent.pm
index 9f385b06d1..c21096d724 100644
--- a/lib/Net/netent.pm
+++ b/lib/Net/netent.pm
@@ -113,7 +113,7 @@ The gethost() functions do this in the Perl core:
That means that the address comes back in binary for the
host functions, and as a regular perl integer for the net ones.
This seems a bug, but here's how to deal with it:
-
+
use strict;
use Socket;
use Net::netent;
@@ -154,7 +154,7 @@ This seems a bug, but here's how to deal with it:
}
}
}
-
+
=head1 NOTE
While this class is currently implemented using the Class::Template
diff --git a/lib/Tie/Hash.pm b/lib/Tie/Hash.pm
index 20b6777978..2117c54c18 100644
--- a/lib/Tie/Hash.pm
+++ b/lib/Tie/Hash.pm
@@ -98,7 +98,7 @@ L<Config> module. While these do not utilize B<Tie::Hash>, they serve as
good working examples.
=cut
-
+
use Carp;
sub new {
diff --git a/lib/diagnostics.pm b/lib/diagnostics.pm
index 31e7670b82..3492bd3e28 100755
--- a/lib/diagnostics.pm
+++ b/lib/diagnostics.pm
@@ -150,8 +150,8 @@ You have to to this instead, and I<before> you load the module.
BEGIN { $diagnostics::PRETTY = 1 }
I could start up faster by delaying compilation until it should be
-needed, but this gets a "panic: top_level"
-when using the pragma form in 5.001e.
+needed, but this gets a "panic: top_level" when using the pragma form
+in Perl 5.001e.
While it's true that this documentation is somewhat subserious, if you use
a program named I<splain>, you should expect a bit of whimsy.
diff --git a/lib/overload.pm b/lib/overload.pm
index 20411ea576..ec874ec8d7 100644
--- a/lib/overload.pm
+++ b/lib/overload.pm
@@ -1,12 +1,26 @@
package overload;
+sub nil {}
+
sub OVERLOAD {
$package = shift;
my %arg = @_;
- my $hash = \%{$package . "::OVERLOAD"};
+ my ($sub, $fb);
+ $ {$package . "::OVERLOAD"}{dummy}++; # Register with magic by touching.
+ *{$package . "::()"} = \&nil; # Make it findable via fetchmethod.
for (keys %arg) {
- $hash->{$_} = $arg{$_};
+ if ($_ eq 'fallback') {
+ $fb = $arg{$_};
+ } else {
+ $sub = $arg{$_};
+ if (not ref $sub and $sub !~ /::/) {
+ $sub = "${'package'}::$sub";
+ }
+ #print STDERR "Setting `$ {'package'}::\cO$_' to \\&`$sub'.\n";
+ *{$package . "::(" . $_} = \&{ $sub };
+ }
}
+ ${$package . "::()"} = $fb; # Make it findable too (fallback only).
}
sub import {
@@ -18,41 +32,47 @@ sub import {
sub unimport {
$package = (caller())[0];
- my $hash = \%{$package . "::OVERLOAD"};
+ ${$package . "::OVERLOAD"}{dummy}++; # Upgrade the table
shift;
for (@_) {
- delete $hash->{$_};
+ if ($_ eq 'fallback') {
+ undef $ {$package . "::()"};
+ } else {
+ delete $ {$package . "::"}{"(" . $_};
+ }
}
}
sub Overloaded {
- ($package = ref $_[0]) and defined %{$package . "::OVERLOAD"};
+ my $package = shift;
+ $package = ref $package if ref $package;
+ $package->can('()');
}
sub OverloadedStringify {
- ($package = ref $_[0]) and
- defined %{$package . "::OVERLOAD"} and
- exists $ {$package . "::OVERLOAD"}{'""'} and
- defined &{$ {$package . "::OVERLOAD"}{'""'}};
+ my $package = shift;
+ $package = ref $package if ref $package;
+ $package->can('(""')
}
sub Method {
- ($package = ref $_[0]) and
- defined %{$package . "::OVERLOAD"} and
- $ {$package . "::OVERLOAD"}{$_[1]};
+ my $package = shift;
+ $package = ref $package if ref $package;
+ $package->can('(' . shift)
}
sub AddrRef {
- $package = ref $_[0];
- bless $_[0], Overload::Fake; # Non-overloaded package
+ my $package = ref $_[0];
+ return "$_[0]" unless $package;
+ bless $_[0], overload::Fake; # Non-overloaded package
my $str = "$_[0]";
bless $_[0], $package; # Back
- $str;
+ $package . substr $str, index $str, '=';
}
sub StrVal {
- (OverloadedStringify) ?
- (AddrRef) :
+ (OverloadedStringify($_[0])) ?
+ (AddrRef(shift)) :
"$_[0]";
}
@@ -486,9 +506,13 @@ induces diagnostic messages.
=head1 BUGS
Because it is used for overloading, the per-package associative array
-%OVERLOAD now has a special meaning in Perl.
+%OVERLOAD now has a special meaning in Perl. The symbol table is
+filled with names looking like line-noise.
-As shipped, mathemagical properties are not inherited via the @ISA tree.
+For the purpose of inheritance every overloaded package behaves as if
+C<fallback> is present (possibly undefined). This may create
+interesting effects if some package is not overloaded, but inherits
+from two overloaded packages.
This document is confusing.