Type | Bug | Status | built | Date | 14-Aug-2013 19:16 |
---|---|---|---|---|---|
Version | r3 master | Category | Datatype | Submitted by | Ladislav |
Platform | All | Severity | major | Priority | normal |
Summary | Rebinding for better compatibility between functions and closures |
---|---|
Description |
The example code below shows an incompatibility between functions and closures in R3 that can be resolved using rebinding. Other positive effects of rebinding would be: * rebinding is faster than binding (no word search in context needs to be performed) * rebinding is more "natural" and "intellingent", only the words bound to the source context get rebound to the dst context, which is what resolves the incompatibility described below * rebinding is less "brittle" than binding (the binding algorithm used is not as fast and reentrant as rebinding) |
Example code |
; example of an R3 function with "special binding" of its body ; create a function with "normally" bound body ; and keep the original of its body for future use f: make function! reduce [[value] f-body: [value + value]] ; some tests f 1 ; == 2 f 2 ; == 4 f 3 ; == 6 ; adjust the binding change f-body 'value value: 1 ; some tests f 1 ; == 2 f 2 ; == 3 f 3 ; == 4 ; example of an R3 closure with "special binding" of its body ; create a "normal" closure ; and keep the original of its body for future use f: make closure! reduce [[value] f-body: [value + value]] ; some tests f 1 ; == 2 f 2 ; == 4 f 3 ; == 6 ; adjust the binding change f-body 'value value: 1 ; some tests f 1 ; == 2 f 2 ; == 4 f 3 ; == 6 |
Assigned to | n/a | Fixed in | - | Last Update | 11-Mar-2014 19:17 |
---|
Comments | |
---|---|
(0003927)
Ladislav 15-Aug-2013 13:52 |
In the core-tests suite. |
(0003928)
Ladislav 15-Aug-2013 14:26 |
Fixed by https://github.com/rebol/rebol/pull/128 |
Date | User | Field | Action | Change |
---|---|---|---|---|
11-Mar-2014 19:17 | Ladislav | Status | Modified | pending => built |
20-Aug-2013 22:08 | Ladislav | Summary | Modified | Rebinding for compatibility between functions and closures => Rebinding for better compatibility between functions and closures |
19-Aug-2013 08:28 | Ladislav | Comment : 0003928 | Modified | - |
19-Aug-2013 08:28 | Ladislav | Comment : 0003928 | Modified | - |
15-Aug-2013 22:41 | Ladislav | Severity | Modified | minor => major |
15-Aug-2013 14:27 | Ladislav | Category | Modified | Unspecified => Datatype |
15-Aug-2013 14:26 | Ladislav | Status | Modified | submitted => pending |
15-Aug-2013 14:26 | Ladislav | Comment : 0003928 | Added | - |
15-Aug-2013 13:52 | Ladislav | Comment : 0003927 | Added | - |
15-Aug-2013 04:49 | BrianH | Comment : 0003923 | Removed | - |
15-Aug-2013 04:49 | BrianH | Comment : 0003923 | Added | - |
14-Aug-2013 19:44 | Ladislav | Description | Modified | - |
14-Aug-2013 19:31 | Ladislav | Description | Modified | - |
14-Aug-2013 19:31 | Ladislav | Code | Modified | - |
14-Aug-2013 19:16 | Ladislav | Ticket | Added | - |