World: r3wp
[!REBOL3-OLD1]
older newer | first last |
Ladislav 4-Jul-2009 [16022x2] | yes, but the detection uses the Marking algorithm, nevertheless (at least AFAIK) |
so, the same approach as for MOLD | |
BrianH 4-Jul-2009 [16024] | That will have to change when task! is fixed. |
Ladislav 4-Jul-2009 [16025x2] | hmm, marking is used for Collect-words and some other things, too |
and GC, of course | |
BrianH 4-Jul-2009 [16027x2] | These would all need to be considered EQUAL?: >> a: [z] append/only a a == [z [...]] >> b: [z [z]] append/only second b second b == [z [...]] >> c: [z [z]] append/only second c c == [z [z [...]]] |
Simple cycle detection wouuldn't help there - you would need cycle tracing. | |
Ladislav 4-Jul-2009 [16029] | that depends on the quantity of marking bits, if you have only one marking bit, you can just detect cycle, if you have 32 bits, you can detect the index |
BrianH 4-Jul-2009 [16030] | Cycle detection would be good enough to let you throw an informative error though, without getting as far as a stack overflow. |
Ladislav 4-Jul-2009 [16031x2] | btw, in the Identity article I wrote an equivalent? version, that works with cyclic structures |
(but it is slow, not having any additional marking data available) | |
BrianH 4-Jul-2009 [16033x5] | Ladislav, the cyclic structures above are not the same structure, but the results would need to be considered EQUAL?. Unless we declare that cyclic structures need to have the same structure to be declared equal - then we can use a stack of ref/index for the structure detection. |
Simple marking wouldn't work, unless we locked the data for the task first. | |
Since that data is complex and has references such marking couuld easily deadlock. | |
It all depends on how sharing of data between tasks is done. It looks (currently) like Carl is thinking that PROTECTed series would be sharable - this would mean that large swaths of the data in memory would be unmodifiable, or duplicated. This makes functional or lock-free datastructures even more important for R3. | |
Updated the comment according to the above discussion. | |
Ladislav 4-Jul-2009 [16038] | Simple marking wouldn't work, unless we locked the data for the task first. - that has to be done for the GC as well as for MOLD etc. anyway |
BrianH 4-Jul-2009 [16039] | Yeah, buut that would only help for cycle detection, not for structural equivalence. |
Ladislav 4-Jul-2009 [16040x2] | try this in R3 >> do http://www.rebol.org/download-a-script.r?script-name=identity.r Script: "Identity.r" Version: none Date: 7-May-2009/8:59:07+2:00 Script: "Contexts" Version: none Date: 12-May-2006/15:58+2:00 Script: "Closure" Version: none Date: 11-May-2009/19:13:51+2:00 Script: "Apply" Version: none Date: 7-May-2009/9:25:31+2:00 == make function! [[ "finds out, if the VALUE is mutable" value [any-type!] /local r ][ parse head insert/only copy [] get/any 'value [ any-function! | error! | object! | port! | series! | bitset! | struct! | set r any-word! ( either bind? :r [r: none] [r: [skip]] ) r ] ]] >> a: [z] append/only a a == [z [...]] >> b: [z [z]] append/only second b second b == [z [...]] >> c: [z [z]] append/only second c c == [z [z [...]]] >> equal-state? a a == true >> equal-state? a b == true >> equal-state? a c == true |
Apply and Closure not needed, but the script was written for R2 | |
BrianH 4-Jul-2009 [16042] | Mere cycle detection is only good enough to throw a good error. To determine equivalence you need to compare different cycles to see if they are the same shape. Or topologically equivalent if you are ambitious. |
Ladislav 4-Jul-2009 [16043x2] | as I said: if we have 32 bits available for marking, it *is* enough |
(and, said 32 bits are needed only for block-like data values, for other values, like objects, one bit is plenty) | |
BrianH 4-Jul-2009 [16045] | You didn't post the relevant code so I can't evaluate what you are saying. I'm searching for the code now. |
Ladislav 4-Jul-2009 [16046x2] | do http://www.rebol.org/download-a-script.r?script-name=identity.r |
(it is posted above) | |
BrianH 4-Jul-2009 [16048] | I got the link, but am reading it to find the code. |
Ladislav 4-Jul-2009 [16049] | (R2 code, unadjusted for R3) |
BrianH 4-Jul-2009 [16050] | There's a lot of code in there, not all of it relavant. |
Ladislav 4-Jul-2009 [16051x2] | ...but this variant does not use Mark bits, since those are available only in C |
search for EQUAL-STATE? | |
BrianH 4-Jul-2009 [16053] | I'm translating while I read, boith to R3 and C. |
Ladislav 4-Jul-2009 [16054] | LOL |
BrianH 4-Jul-2009 [16055x2] | It's not as hard as it sounds :) |
Already found some R2-isms, and I'm not just talking about the reflective accessors. Assumed case-sensitive equivalence of words, for instance. | |
Ladislav 4-Jul-2009 [16057] | yes, lots of those, no adjustment for R3, it is a surprise that it works at all |
BrianH 4-Jul-2009 [16058] | Words in R3 preserve the case they are typed in, but are considered equivalent on a case-insensitive basis. |
Ladislav 4-Jul-2009 [16059x2] | ...but that is the case of R2 words too |
(the variants having different case are "automatic aliases", as I call them) | |
BrianH 4-Jul-2009 [16061] | R2 words preserve the case they are *first* typed in, not the case they are in every time. |
Ladislav 4-Jul-2009 [16062] | I would need to see an example where it differs |
BrianH 4-Jul-2009 [16063] | I noticed the difference before, but am not able to replicate it now :( |
Ladislav 4-Jul-2009 [16064] | nevermind, we will "rediscover" it :-D |
BrianH 4-Jul-2009 [16065] | In any case, for R3 line 502: if strict-not-equal? mold :a mold :b [return false] should probably be this: if not-equal? mold :a mold :b [return false] |
Ladislav 4-Jul-2009 [16066] | well, that is "in transition" still |
BrianH 4-Jul-2009 [16067] | Probably for R2 as well, if your statement about R2 case-preserving is true. |
Ladislav 4-Jul-2009 [16068] | depends on the level of strictness we want to achieve for the said EQUAL-STATE? function... |
BrianH 4-Jul-2009 [16069] | Unless you want >> equal-state? [A] [a] == false |
Ladislav 4-Jul-2009 [16070x2] | yes, that is what I achieved, as it looks |
(lots of possibilities, and it was written long ago) | |
older newer | first last |