diff options
author | Casey R. Tweten <crt@kiski.net> | 2000-11-08 15:46:41 -0500 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-11-09 04:25:05 +0000 |
commit | ab6e6725bd64e0f27f463fa43d9410fc9a13d104 (patch) | |
tree | 979c1f6df88e048098e1ff7689ea2debef3feaeb /lib | |
parent | 3a26a9866592cf64fe5b5d40a8e70e53c7ef85b4 (diff) | |
download | perl-ab6e6725bd64e0f27f463fa43d9410fc9a13d104.tar.gz |
Class::Struct at compile time
Message-ID: <Pine.OSF.4.21.0011082041360.8238-100000@home.kiski.net>
p4raw-id: //depot/perl@7617
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Class/Struct.pm | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/Class/Struct.pm b/lib/Class/Struct.pm index ac1fb4736d..cf98cd7a1c 100644 --- a/lib/Class/Struct.pm +++ b/lib/Class/Struct.pm @@ -14,7 +14,7 @@ require Exporter; @ISA = qw(Exporter); @EXPORT = qw(struct); -$VERSION = '0.58'; +$VERSION = '0.59'; ## Tested on 5.002 and 5.003 without class membership tests: my $CHECK_CLASS_MEMBERSHIP = ($] >= 5.003_95); @@ -51,6 +51,16 @@ sub printem { sub DESTROY { } } +sub import { + my $self = shift; + + if ( @_ ) { + &struct; + } else { + $self->export_to_level( 1, $self, @EXPORT ); + } +} + sub struct { # Determine parameter list structure, one of: @@ -242,6 +252,10 @@ Class::Struct - declare struct-like datatypes as Perl classes # declare struct, based on array, implicit class name: struct( ELEMENT_NAME => ELEMENT_TYPE, ... ); + # Declare struct at compile time + use Class::Struct CLASS_NAME => [ ELEMENT_NAME => ELEMENT_TYPE, ... ]; + use Class::Struct CLASS_NAME => { ELEMENT_NAME => ELEMENT_TYPE, ... }; + package Myobj; use Class::Struct; @@ -326,6 +340,15 @@ element name will be defined as an accessor method unless a method by that name is explicitly defined; in the latter case, a warning is issued if the warning flag (B<-w>) is set. +=head2 Class Creation at Compile Time + +C<Class::Struct> can create your class at compile time. The main reason +for doing this is obvious, so your class acts like every other class in +Perl. Creating your class at compile time will make the order of events +similar to using any other class ( or Perl module ). + +There is no significant speed gain between compile time and run time +class creation, there is just a new, more standard order of events. =head2 Element Types and Accessor Methods @@ -525,6 +548,10 @@ struct's constructor. =head1 Author and Modification History +Modified by Casey Tweten, 2000-11-08, v0.59. + + Added the ability for compile time class creation. + Modified by Damian Conway, 1999-03-05, v0.58. Added handling of hash-like arg list to class ctor. |