-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
314 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,5 @@ @article{1993-kay | |
acmid = {155364}, | ||
publisher = {ACM}, | ||
address = {New York, NY, USA}, | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package Person; | ||
|
||
sub new { | ||
my $class = shift; | ||
my $self = { | ||
name => shift, | ||
t => "person" | ||
}; | ||
|
||
my $closure = sub { | ||
die "cannot access fields outside the class" unless caller eq __PACKAGE__; | ||
my ($field, $value) = @_; | ||
die "no field called: $field" unless exists $self->{$field}; | ||
if ($value) {#setter | ||
$self->{$field} = $value; | ||
} | ||
return $self->{$field};#getter | ||
}; | ||
|
||
bless $closure, $class; | ||
return $closure; | ||
} | ||
|
||
sub t { | ||
die "t is protected!" unless caller->isa(__PACKAGE__); | ||
my($self, $value )= @_; | ||
return $self->("t", $value); | ||
} | ||
|
||
sub _info_private { | ||
die "_info_private is private!" unless caller eq __PACKAGE__; | ||
my( $self ) = @_; | ||
print "My name: ",$self->("name"),"\n"; | ||
} | ||
|
||
sub _info_protected { | ||
die "_info_protected is protected!" unless caller->isa(__PACKAGE__); | ||
my( $self ) = @_; | ||
print "I am a: ",$self->("t"),"\n"; | ||
} | ||
|
||
sub info { | ||
my( $self ) = @_; | ||
_info_private(@_); | ||
_info_protected(@_); | ||
print "----------------------------\n"; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package Student; | ||
use Person; | ||
our @ISA = qw(Person); | ||
|
||
sub new { | ||
my ($class, @args) = @_; | ||
$self = $class->SUPER::new(@args); | ||
#$self->{t} = "student";#error the object is not a HASH | ||
#$self->("t", "student");#limited the direct access | ||
$self->t("student"); | ||
bless $self, $class; | ||
return $self; | ||
} | ||
|
||
sub use_protected { | ||
my( $self, @args ) = @_; | ||
# $self->_info_private(@args); #_info_private is private! | ||
$self->_info_protected(@args); | ||
} | ||
|
||
1; |
Oops, something went wrong.