develooper Front page | perl.perl5.porters | Postings from May 2000

Re: Proposed pragma: readonly - summary

Tom Christiansen
May 21, 2000 10:35
Re: Proposed pragma: readonly - summary
Message ID:
>My sad conclusion is this:

>	const $READONLY = 99 ; # OR use readonly '$READONLY' => 99 ;
>	*MYREADONLY = \'splat!' ;
>	print $READONLY ; # Yep, prints "splat!" and no warnings

>Looks like you can't have genuinely readonly scalars in perl unless you
>use ties...

Why should this be an issue?  Just because you can't diddle $foo doesn't
mean you can't diddle the *foo typeglob.

>Maybe we should have

>	my $READONLY : readonly = 'Initialised' ;

>as Barrie Slaymaker suggested after all?

Coming soon from a Larry near you:

    At some point, we'll enable the use of a C<constant> attribute
    on variable declarations:

	my $PI : constant = 4 * atan2(1,1);

    This has all the advantages of being a variable rather than a
    subroutine.  It has all the disadvantages of not being implemented yet.

--tom Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About