lisch@mentor.com (Ray Lischner) (09/05/90)
Below is a feature that I would like to see added to Perl; it mostly helps error checking, but if the optimizer can use the information, then so much the better. const(LIST) const LIST marks as constant the variables named in the LIST. A constant variable can be initialized, but not changed after it is initialized. For example: const($c) = 1; # initialize $c $c = 2; # error! const($_IOREAD, $_IOWRT, $_IONBF, $_IOMYBUF, $_IOEOF, $_IOERR, $_IOSTRG) = (01, 02, 04, 010, 020, 040, 0400); -- Ray Lischner UUCP: {uunet,apollo,decwrl}!mntgfx!lisch
flee@guardian.cs.psu.edu (Felix Lee) (09/12/90)
> const($c) = 1; # initialize $c
It makes more sense this way:
$c = 1;
readonly($c);
or
readonly($c = 1);
If you want a const declaration rather than a readonly statement, you
can fake it with subroutines:
sub c { 1; }
In fact, the makelib script uses this style of constant.
--
Felix Lee flee@cs.psu.edu