REBOL3 tracker
  0.9.12 beta
Ticket #0002230 User: anonymous

Project:

Previous Next
Short URL: http://issue.cc/r3/2230
rss
TypeIssue Statussubmitted Date29-Jul-2015 15:09
Versionr3 master CategoryUnspecified Submitted byfork
PlatformAll Severityminor Prioritynormal

Summary PROTECT/DEEP of lit-word or lit-path should error
Description PROTECT 'FOO and PROTECT FOO are different; one protects a word from being used to change the variable to which it is bound, and the other protects the value itself. So for protecting the value:

>> foo: [a [b c] d]
>> protect foo

>> append foo 'muhaha
** Script error: protected value or series - cannot modify
** Where: append
** Near: append foo 'muhaha

>> foo: 10
== 10

In contrast, protecting the word:

>> foo: [a [b c] d]
>> protect 'foo

>> append foo 'muhaha
== [a [b c] d muhaha]

>> foo: 10
** Script error: protected variable - cannot modify: foo:

But the /DEEP refinement does something weird with the lit-word (or lit-path) protect, to suddenly mean you want to protect the word *and* the series:

>> foo: [a [b c] d]
>> protect/deep 'foo

>> append foo 'muhaha
** Script error: protected value or series - cannot modify
** Where: append
** Near: append foo 'muhaha

>> append foo/2 'muhaha
** Script error: protected value or series - cannot modify
** Where: append
** Near: append foo/2 'muhaha

>> foo: 10
** Script error: protected variable - cannot modify: foo:

It's a little tricky to begin with, but this just makes things worse. /DEEP should be an error if the target is just a word or path lookup itself. This would help prevent cases where people accidentally wind up protecting the word when they really meant to protect the value deeply.
Example code

			

Assigned ton/a Fixed in- Last Update29-Jul-2015 15:15


Comments

Date User Field Action Change
29-Jul-2015 15:15 Fork Description Modified -
29-Jul-2015 15:09 Fork Ticket Added -