Type | Wish | Status | submitted | Date | 30-Sep-2014 01:21 |
---|---|---|---|---|---|
Version | r3 master | Category | Unspecified | Submitted by | fork |
Platform | All | Severity | major | Priority | normal |
Summary | Make CONSTRUCT (OBJECT/SAFE) produce same output as OBJECT on acceptable input |
---|---|
Description |
One early question that I wondered about--after seeing usages in scripts--was whether or not to use LIT-WORD! vs. WORD! in headers. Rebol [ Title: "My cool script" License: 'bsd Language: English ] In the Rebol2 documentation, Carl seems to prescribe LIT-WORD! http://www.rebol.com/docs/core23/rebolcore-5.html Yet the CONSTRUCT primitive, which is used to make an object as data without any side effect, accepts non-lit-words as if they had been lit-words. It also ignores any additional data that doesn't immediately follow a SET-WORD! >> construct [foo: 'a print "Hello" bar: b] == make object! [ foo: 'a bar: 'b ] Note that you would get a very different response from the typical OBJECT construction: >> object [foo: 'a print "Hello" bar: b] Hello ** Script error: b has no value ** Where: make object ** Near: make object! append blk none In trying to impose some sanity on this, I came up with a rule. CONSTRUCT (which I've suggested should be called OBJECT/SAFE or similar) will not do any evaluation of arbitrary code, and will reject as input any input that OBJECT would generate a different result from. This would help canonize the headers used in script libraries and prevent people from slipping out-of-band "junk" into them. |
Example code |
>> proposed.object/safe [foo: 'a bar: b] ** Error >> proposed.object/safe [print "No evaluation!"] ** Error >> proposed.object/safe [foo: 'a bar: 42] == make object! [ foo: 'a bar: 42 ] |
Assigned to | n/a | Fixed in | - | Last Update | 20-Jan-2015 06:43 |
---|
Comments | |
---|---|
(0004517)
abolka 3-Oct-2014 02:52 |
Sounds like a good idea and a good tool to have in the box.
I wouldn't have it replace the current CONSTRUCT behaviour, as CONSTRUCT serves a different purpose: "give me whatever you wish, and I'll safely what I can". Whereas the proposed tool I'd describe as: "give me whatever you wish, and I'll do something safely or error out if something unsafe is around." So that's two modes of a sanitiser: - CONSTRUCT: don't do any evaluation of arbitrary code, ignore unsafe parts - *proposed*: don't do any evaluation of arbitrary code, error for unsafe parts Given that view, maybe it's best for the proposed behaviour to become a refinement of CONSTRUCT, such as CONSTRUCT/strict. |
(0004528)
BrianH 21-Oct-2014 18:06 |
There is a CONSTRUCT/only that works the way you want.
The default behavior is there to make headers easier to write. The flexibility is intentional, and we even cleaned up its semantics in Rebol 3 (added new keywords, made datatypes more consistent). The /only option is there for people who need more strict semantics. Neither of them execute code though. |
Date | User | Field | Action | Change |
---|---|---|---|---|
20-Jan-2015 06:43 | abolka | Type | Modified | Issue => Wish |
20-Jan-2015 06:24 | abolka | Code | Modified | - |
21-Oct-2014 18:47 | BrianH | Comment : 0004528 | Modified | - |
21-Oct-2014 18:07 | BrianH | Comment : 0004528 | Modified | - |
21-Oct-2014 18:06 | BrianH | Comment : 0004528 | Added | - |
3-Oct-2014 03:21 | abolka | Comment : 0004517 | Modified | - |
3-Oct-2014 02:52 | abolka | Comment : 0004517 | Modified | - |
3-Oct-2014 02:52 | abolka | Comment : 0004517 | Modified | - |
3-Oct-2014 02:52 | abolka | Comment : 0004517 | Modified | - |
3-Oct-2014 02:52 | abolka | Comment : 0004517 | Added | - |
30-Sep-2014 01:47 | fork | Summary | Modified | Make CONSTRUCT (OBJECT/SAFE) produce same output as OBJECT => Make CONSTRUCT (OBJECT/SAFE) produce same output as OBJECT on acceptable input |
30-Sep-2014 01:47 | fork | Description | Modified | - |
30-Sep-2014 01:21 | fork | Ticket | Added | - |