[Types-sig] const (was: PyDL RFC 0.02)
Greg Stein
gstein@lyra.org
Tue, 28 Dec 1999 14:40:22 -0800 (PST)
On Wed, 29 Dec 1999, skaller wrote:
> Greg Stein wrote:
> > On Tue, 28 Dec 1999, Paul Prescod wrote:
> > > Greg Stein wrote:
> > > > p.s. I'd recommend assignment enforcement over the notion of const; the
> > > > former seems to be more easily enforcable at runtime.
> > >
> > > I think we need both. We need to be able to enforce the TYPES of
> > > assignments and we need to sometimes say that an object is not
> > > modifiable, for all of the things we currently use tuples, files open
> > > for read and other read-only objects for.
> >
> > Um... Are you suggesting that we add a readonly flag to the list and dict
> > types? Short of that, I'm not sure how you would do "const". IMO, adding a
> > readonly flag to those types seems wrong.
>
> 'const', IMHO, in Paul's name based model, means the name
> cannot be rebound:
>
> const x = 1 # x is always bound to 1
>
> But:
>
> const x = []
> x.append(1) # fine, x is still bound to the same list
>
> This does not require a readonly flag, it can be
> enforced at compile time (in the absence of 'exec'
> statements :-)
Please re-read Paul's posts. In the quoted section above, he says we need
to say "that an object is not modifiable." In a previous post, he had the
following example code:
const [ const Array( Integer )]
These two points said (to me) that he wanted to disable your second
example.
I disagree with the notion of add const-ness to objects. I could agree
with preventing rebinding (more agreement on preventing external
rebinding; less agreement on marking names as not rebindable at all).
If Paul means something else, then I'd ask for clarification.
Cheers,
-g
--
Greg Stein, http://www.lyra.org/