Hi,
just my two cents...
> [EMAIL PROTECTED] wrote:
>
> > > > I suggest inline-strings and blocks should be read-only,
> > >
> > > This might be an idea, but then you have more problems when
you
> > > save and then load strings... No, I don't think this would
be a
> > > good solution.
> > >
> >
> [...]
> > What's your reservation with load and save? I have no idea
yet.
> > (and later) a write-protected saved string is changeable after
> > load? or loaded blocks are then write-protected? hm.
thinking..
>
> If literal strings should be made "write-protected" (a better
> approach wuold be a sort of copy-on-modify for series, this has
> been discussed and was proposed mainly by Ladislav), then every
> string you are loading form your data will be made
write-protected
> (because it is "literal").
>
[...]
My suggestion is a little bit different. If you want to have
"Protected Literals" ("Immutable Literals" can
be the term the others may prefer), you can use a simple strategy.
1) You can have two different types:
immutable-block!
mutable-block!
, where the usual literals such as [] are of Immutable-block!
type.
This principle doesn't lead to a big deformation of Rebol, it is
already there - see the object! or list! types. They (sort of)
don't have "normal" literals, you often use expressions like:
make object! [...] or make list! [...] instead
2) For every mutable type you create its immutable counterpart
type.
3) Values of immutable-block! type contain only immutable values.
4) The expressions:
do blk
func args body
work normally for immutable-blocks Blk, Args, Body. If you want to
use them for mutable-blocks, they work like:
do make immutable-block! blk
func make immutable-block! args make immutable-block! body
, this doesn't lead to a big complication for the code, because it
is (sort of) present already - Args/Body are deep copied even now
5) The [a: []] "paradox" doesn't exist anymore, because [] is
immutable. If you want to have a mutable value, you must write:
[a: make mutable-block! []]
, but the last is safe.
Ladislav