Type | Wish | Status | reviewed | Date | 22-Apr-2014 22:02 |
---|---|---|---|---|---|
Version | r3 master | Category | Mezzanine | Submitted by | IngoHohmann |
Platform | All | Severity | minor | Priority | normal |
Summary | make extend bind function body to the object, add /only to not bind |
---|---|
Description |
Currently, you need to 'bind the body of a function manually, to be able to access words in the object. Make this binding automatic, but add an /only refinement to not bind. |
Example code |
>> o: object [p: does [print 'hi]] == make object! [ p: make function! [[][print 'hi]] ] >> extend o 'q does [p] >> o/p hi >> o/q ** Script error: p has no value ** Where: q ** Near: o/q >> extend o 'q does bind [p] o >> o/q hi |
Assigned to | n/a | Fixed in | - | Last Update | 22-Jun-2014 03:08 |
---|
Comments | |
---|---|
(0004462)
BrianH 22-Jun-2014 03:08 |
You might notice that when you bound the function in your example, you actually bound the code block before it was used to make the function. You can't actually rebind a function after it's created, at least not with BIND or IN - that only seems to happen as a side effect of object creation. I'm currently at a bit of a loss as to know how to do this in mezzanine form without rebuilding the function from its SPEC-OF and BODY-OF values; and that function-rebinding-rebuilding function would be cool to make, though it might be more useful separately.
EXTEND was originally intended to make extending an object, a map, or a block in object spec form, more or less the same. It was originally intended for use in the R3 GUI, back before Saphirion started working on it, and I don't think it was used in the GUI code because the design was changed since then, even before Carl released it initially (that's why it won't add a value if it's not truthy, that was specific to something the GUI had to do before it was redesigned). I have no idea whether the GUI or any user code uses it today, but I doubt it (due to that truthy thing). EXTEND seems like too valuable a word to waste on what the function does now. I've always considered it to be up for removal so it doesn't reserve the name EXTEND, or replacement with a different function worthy of the name, or enhancement to the point where it's worth including. Any more ideas? |
Date | User | Field | Action | Change |
---|---|---|---|---|
22-Jun-2014 03:09 | BrianH | Comment : 0004462 | Modified | - |
22-Jun-2014 03:08 | BrianH | Description | Modified | - |
22-Jun-2014 03:08 | BrianH | Code | Modified | - |
22-Jun-2014 03:08 | BrianH | Status | Modified | submitted => reviewed |
22-Jun-2014 03:08 | BrianH | Comment : 0004462 | Added | - |
22-Apr-2014 22:02 | IngoHohmann | Ticket | Added | - |