Reflection/List properties: Difference between revisions

Added some hand-wavy stuff about Perl
(Added some hand-wavy stuff about Perl)
Line 480:
A B I L M N O S U V W X 9 datatype(v)</pre>
 
=={{header|Perl}}==
In Perl's bare-bones native OO system, an object is sometimes nothing more than a hash blessed into a class. It's properties could be simply listed by iterating over the keys. However more complex data structures can be present, so the safest option is always to use <code>Data::Dumper</code> to examine an object.
<lang perl>{
package Point;
use Class::Spiffy -base;
 
field 'x';
field 'y';
}
 
{
package Circle;
use base qw(Point);
field 'r';
}
 
my $p1 = Point->new(x => 8, y => -5);
my $c1 = Circle->new(r => 4);
my $c2 = Circle->new(x => 1, y => 2, r => 3);
 
use Data::Dumper;
say Dumper $p1;
say Dumper $c1;
say Dumper $c2;</lang>
{{out}}
<pre>$VAR1 = bless( {
'x' => 8,
'y' => -5
}, 'Point' );
 
$VAR1 = bless( {
'r' => 4
}, 'Circle' );
 
$VAR1 = bless( {
'r' => 3,
'x' => 1,
'y' => 2
}, 'Circle' );
</pre>
=={{header|Perl 6}}==
 
2,392

edits