World: r3wp
[!REBOL3]
older newer | first last |
BrianH 28-Apr-2010 [2396x2] | Ladislav, for comparison I added the tests from the blog to #1543, #1544 and #1549. Take a look and tell s what you think. English is overrated - clearly, we should be expressing our arguments in REBOL :) |
tell s -> tell us | |
Ladislav 28-Apr-2010 [2398] | Right,Brian, in REBOL it usually is less ambiguous, that is why the Bindology article contains that much Rebol code |
BrianH 28-Apr-2010 [2399x3] | I added your philosophical point tests to the example code of the #1549 ticket, and the practical tests to a comment. Please check both. |
And test them against the build linked above, to see whether they match. There doesn't seem to be a SELFLESS? function yet, so the downsides of the proposal haven't been resolved yet by the posted build. | |
In the posted build, functions are fixed, but closures and loops aren't yet. | |
Ladislav 28-Apr-2010 [2402x3] | If my last tests are more understandable, then I am able to simplify the #1549 wording by removing older text, etc. keeping and explaining only the newer tests |
does that make sense? | |
BTW, I wanted to edit the TO-BINARY function description in R3 documentation to explain the "network bit order", but did not succeed; while I edited some parts of the documentation, now I am unable to log in, and have no idea why (posted a private MSG to Carl in R3 chat, but he may have missed the message?) | |
BrianH 28-Apr-2010 [2405] | Sure. Btw, your philosophical tests pass now, at the expense of other bugs continuing, including the return of #447. The practical tests show the errors in question. Basically, #447, #1528 (for closures), #1529 and #1552 are still problematic. |
Ladislav 28-Apr-2010 [2406] | Is there somewhere I can get A98? |
Graham 28-Apr-2010 [2407] | We are all asking that |
BrianH 28-Apr-2010 [2408] | Updated the practical tests to explicitly test for the missing fixes (except #1552). Go to R3 chat for the link to the build. |
Ladislav 28-Apr-2010 [2409] | OK |
Pekr 28-Apr-2010 [2410x2] | there is no A98, just A97 core, the link is in R3 Chat ... |
http://www.rebol.com/r3/downloads/r3c-a97.exe | |
BrianH 28-Apr-2010 [2412] | I was trying to avoid posting that link in a web-public forum. |
Pekr 28-Apr-2010 [2413] | yes, but why? |
BrianH 28-Apr-2010 [2414] | Don't know :) |
Pekr 28-Apr-2010 [2415] | OK, so I solved it then :-) |
BrianH 28-Apr-2010 [2416x2] | (From chat #7216) Some tests pass, others fail. It's a good start. - The tests in the example code of bug#1549 pass (Ladislav's philosophicals) - The practical tests don't. In particular, bug#447, bug#1528 (for closures), bug#1529 and bug#1552 are still problematic. - We need a SELFLESS? function (or whatever it should be called) to resolve the main downside of the #1549 approach, and we need it for the a98 release. Here are the practical tests that need to pass: ; Objects ob: object [] print same? ob do bind [self] ob print same? ob do in ob [self] ; Functions ob: object [f: func [/x] [do bind/copy [self] 'x]] print same? ob ob/f ; Can't use the context after the function returns. ; This is not a side effect of Ladislav's proposal. ; Functions with a 'self parameter (#1528) ob: object [f: func [/self] [do bind/copy [self] 'self]] print not same? ob ob/f ; Closures (#447) ob: do closure [x] [bind? 'x] 1 print 1 = ob/x print not same? ob do bind [self] ob print not same? ob do in ob [self] ; Closures with a 'self parameter (#1528) ob: do attempt [closure [self] [bind? 'self]] 1 print 1 = attempt [ob/self] print not same? ob do bind [self] ob print not same? ob do in ob [self] ; Closures shouldn't bind 'self unless it is a parameter (#447) print same? self do closure [x] [self] 1 print not same? self do attempt [closure [self] [self]] 1 ; Loops (#1529) ob: repeat x 1 [bind? 'x] print 1 = ob/x print not same? ob do bind [self] ob print not same? ob do in ob [self] ; Loops with a 'self variable (#1529) ob: repeat self 1 [bind? 'self] print 1 = attempt [ob/self] print not same? ob do bind [self] ob print not same? ob do in ob [self] ; Loops shouldn't bind 'self unless it's a variable (#1529) print same? self repeat x 1 [self] print not same? self repeat self 1 [self] See also #1552: There needs to be a way to distinguish selfless contexts from selfish contexts at runtime (a SELFLESS? function), and selfless contexts need to MOLD into DOable syntax (perhaps a different datatype, or a flag). |
New test build, all of Ladislav's and my tests pass. Success, and agreement, yay! | |
Ladislav 29-Apr-2010 [2418x2] | selfless?: func [context [word! object!]] [ make object! [ myself: 'self return same? myself first bind [self] context ] ] |
>> selfless? make object! [] == false >> repeat i 1 [selfless? 'i] == true | |
Rebolek 29-Apr-2010 [2420] | >> upgrade Fetching upgrade check ... ** syntax error: script is missing a REBOL header: http://www.rebol.com/r3/upgrade.r |
Ladislav 29-Apr-2010 [2421x5] | >> f: func [/local x] [selfless? 'x] >> f == true >> f: closure [/local x] [selfless? 'x] >> f == true |
>> selfless? 'rebol == false | |
if we want to have the function faster, this version should suffice: make object! [ set 'selfless? func [context [word! object!]] [ return same? 'self first bind [self] context ] ] | |
optimized: make object! [ set 'selfless? func [context [word! object!]] [ 'self =? first bind [self] context ] ] | |
as it looks, this optimization was "too much", since the function modifies itself, so either we need to always create a new object, like above, or use BIND/COPY at least: make object! [ set 'selfless? func [context [word! object!]] [ 'self =? first bind/copy [self] context ] ] | |
BrianH 29-Apr-2010 [2426] | Thanks, I'll modify the ticket accordingly :) |
Ladislav 29-Apr-2010 [2427] | yes, I found out, that you actually wrote the function in CureCode; is the 'self argument already accetable in functions? |
BrianH 29-Apr-2010 [2428x2] | Yes. All of both our tests pass now in the new build. |
And your version is more secure than mine, which used DO rather than FIRST. | |
Ladislav 29-Apr-2010 [2430] | if the 'self argument is acceptable, then I probably do not have the same version as you do |
BrianH 29-Apr-2010 [2431x5] | I use /local self. I was talking about your 'self =? first bind/copy [self] context vs. my self =? do bind/copy [self] context Mine has a code-injection risk. |
So I switched that line for yours :) | |
Strangely enough, the code injection risk doesn't come from the DO vs. FIRST, it comes from the self vs. 'self. We can't use :self with =? in R3 because self is a frame! that evaluates to an object!, not an object! itself. | |
Another way to resolve the risk would be to change the line to this: :self =? do bind/copy [:self] context | |
Or to put a [none!] typespec after /local self. | |
Ladislav 29-Apr-2010 [2436x2] | according to Time-block my version is a little bit faster, but that should not matter |
>> f: func [/local self] [] ** Script error: duplicate variable specified: self ** Where: make func ** Near: make function! copy/deep reduce [spec body] | |
BrianH 29-Apr-2010 [2438] | No, that absolutely matters, because this is a mezzanine that won't be turned into a native unless it gets used a *lot*. Carl is convinced that the function isn't critical, so we have to make due with a mezzanine, if he puts it in at all. And I will insist. |
Ladislav 29-Apr-2010 [2439] | (still not working here, and I downloaded again to make sure |
BrianH 29-Apr-2010 [2440] | It only works in the test builds. And that was one of my tests, so if it doesn't pass I will be surprised. |
Steeve 29-Apr-2010 [2441] | Carl is convinced that the function isn't criticall He's not the only one :) |
Ladislav 29-Apr-2010 [2442] | yes, I used r3c-a97.exe as downloaded just now |
BrianH 29-Apr-2010 [2443x2] | Hey, it is the only way to get me to accept #1549. Use the second test build (it came out while you were asleep last night). |
http://www.rebol.com/r3/downloads/r3c2-a97.exe | |
Ladislav 29-Apr-2010 [2445] | aha, ok, a different name... |
older newer | first last |