Type | Wish | Status | dismissed | Date | 25-Mar-2010 07:32 |
---|---|---|---|---|---|
Version | alpha 97 | Category | Native | Submitted by | BrianH |
Platform | All | Severity | minor | Priority | normal |
Summary | BIND /no-self option |
---|---|
Description |
BIND block! currently does a trick where the hidden 'self field of the context is bound anyways. But there are times that we don't want to do this, when we don't want any existing binding of 'self overriden in the code block. Look at #447 and #1529 for native cases of this concern. However, the solution to #447 proves that the 'self trick can be turned off for native code as needed: Closures no longer bind 'self in their code block when they are created. I would like to make that option visible, usable by mezzanine code through the BIND function. A BIND/no-self option would turn off the 'self binding trick. The rest of what BIND does would be the same. This ticket is the opposite of #1544. If that ticket is accepted, this one should be dismissed, and vice-versa. |
Example code |
; Desired behavior >> same? 'self first bind [self] context [] == false >> same? 'self first bind/no-self [self] context [] == true |
Assigned to | n/a | Fixed in | - | Last Update | 2-May-2010 20:45 |
---|
Comments | |
---|---|
(0002122)
BrianH 25-Mar-2010 07:34 |
Note: I don't like the name /no-self, but can't think of anything better (/only is used already by BIND to mean /shallow). If someone comes up with a better name, please note it in a comment here and we will change the Summary, Description and Example code accordingly. |
(0002263)
BrianH 28-Apr-2010 08:10 |
Noone has come forward in favor of this proposal so far. Everyone seems to prefer #1544, or going back to R2 object behavior. If there are no takers, I'll dismiss this proposal tomorrow. |
(0002267)
BrianH 28-Apr-2010 22:05 |
Here are tests to illustrate the practical effects of this proposal, taken from http://www.rebol.net/cgi-bin/r3blog.r?view=0312#comments
ob: object [] print same? ob do bind [self] ob print same? ob do in ob [self] print not same? ob do bind/no-self [self] ob ob: object [f: func [/x] [do bind/copy [self] 'x]] print error? try [ob/f] ob: object [f: func [/x] [do bind/copy/no-self [self] 'x]] print same? ob ob/f ob: repeat x 1 [bind? 'x] print 1 = ob/x print same? ob do bind [self] ob print same? ob do in ob [self] print not same? ob do bind/no-self [self] ob ob: repeat self 1 [bind? 'self] print 1 = attempt [ob/self] print error? try [do bind [self] ob] print error? try [do in ob [self]] print not same? ob do bind/no-self [self] ob All print statements should print "true". The ones with ERROR? are the core of the proposal. |
(0002295)
BrianH 2-May-2010 20:45 |
Dismissed in alpha 98 in favor of #1549. |
Date | User | Field | Action | Change |
---|---|---|---|---|
2-May-2010 20:45 | BrianH | Status | Modified | submitted => dismissed |
2-May-2010 20:45 | BrianH | Comment : 0002295 | Added | - |
28-Apr-2010 22:05 | BrianH | Comment : 0002267 | Added | - |
28-Apr-2010 08:10 | BrianH | Comment : 0002263 | Added | - |
25-Mar-2010 10:31 | BrianH | Description | Modified | - |
25-Mar-2010 07:56 | BrianH | Comment : 0002122 | Modified | - |
25-Mar-2010 07:35 | BrianH | Description | Modified | - |
25-Mar-2010 07:35 | BrianH | Code | Modified | - |
25-Mar-2010 07:34 | BrianH | Comment : 0002122 | Added | - |
25-Mar-2010 07:32 | BrianH | Ticket | Added | - |