From: David M. Lloyd [mailto:[EMAIL PROTECTED]]
> On Thu, 1 Nov 2001, Garrett Goebel wrote:
> > On Wed, 31 Oct 2001, David Nesting wrote:
> > > On Tue, Oct 30, 2001, Aaron Sherman wrote:
> > > : Yep, but in Perl5, this was never very clean or obvious
> > > : to the casual programmer. Constants have been coming of
> > > : age in Perl, and they're kind of scary if they're not
> > > : constant.
> > >
> > > On one hand, one might say that a developer changing a
> > > constant's binding in order to change its value is probably
> > > doing so because he knows what he's doing.  As I understand
> > > things, constants are really just read-only variables.  Do
> > > we necessarily want to make a special case out of them and
> > > make the variable read-only as well as locking down the
> > > symbol itself against re-binding?
> >
> > One can always turn that argument around, and say that the
> > developer may want to lock down both the variable's binding
> > and the bound value... because he wants to depend on it
> > (always) doing what he wants it to do. What are we going to
> > have for variable bindings?
> 
> A developer shouldn't need to lock down that binding at least
> for lexically scoped vars, because what matters is the value
> in this case. And as for global constants, what about:

Except that in Perl6, I'll be able to easily mess with lexically scoped vars
in your modules if I want to. Remember Damian's discussion about injecting
and accessing lexicals in a caller's scope in the context of Aspect Oriented
Programming (AOP)?

Perhaps you want to nail some things down that you want to be able to depend
on? Maybe someone'll even put modules out on CPAN that mess with other core
modules' lexical vars? Then core module authors'll start getting bug reports
because someone abused their code in a manner they wish'd they could have
explicitly forbidden.

Isn't this basically a subset of the same topic that drove Ken Fox into
shock and dismay not that long ago? Though I believe KENFOX, was more
worried about the loss of data-hiding with Perl6's lexicals. Was that ever
resolved? Will there be a way in Perl6 to explicitly state that my $foo is
inaccessible outside its scope?

I know Perl isn't commonly associated with Bondage and Discipline... but
can't Perl make it possible for the BnD Perl programmers out there have it
if they want it? A lot of people think we're sadomasochists for programming
in Perl anyway ;) What's the addition of a little semantics to up the
dominatrix of unsafe constructs?

 
> sub MY_CONSTANT () { 1234; }
> 
> Using variables for constants in this sense seems weird to me. :-)

Put that way, I'd kind of agree. Constant variables? variable constants? Its
a pretty ugly oxymoron. But that doesn't matter if it's already writ in
stone for Perl6...

Exegesis 2 did say that:
>
> my int ($pre, $in, $post) is constant = (0..2);

Means that you are asking for compile time optimizations, and agreeing not
to bless references to, or ascribe run-time properties to those scalars. So
we've already got variables with constant values. 

I guess my question is, does the compile time optimization for the above
case imply that you can't later do:

  $pre := $post;

If it doesn't then I'll cease and desist... If it does, then wouldn't:

  my scalar $foo is constant = 'bar';

be the 'type' general way to make both a scalar variable binding and its
value constant?

Reply via email to