World: r3wp
[!REBOL3-OLD1]
older newer | first last |
BrianH 4-Jul-2009 [16034x4] | 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) | |
BrianH 4-Jul-2009 [16072] | You do topological comparison here, not marking. |
Ladislav 4-Jul-2009 [16073x4] | yes, I am actually unable to do marking in Rebol |
but, if you want a model, I can write one | |
do you know how many bits can I use for marking? | |
(or is it just one bit? - in that case it indeed is a problem) | |
BrianH 4-Jul-2009 [16077] | Well, my point was that marking isn't enough here, and that this kind of comparison (the kind in equal-state?) is needed. |
Ladislav 4-Jul-2009 [16078] | so, the question is, how many marking bits are available |
BrianH 4-Jul-2009 [16079x3] | Only Carl has that answer. Still reading... |
You would have to do something similar to a simplified EQUAL-STATE? even in a C version. There will never be enough bits for marking because every concurrent instance of your comparison would need its own set. Having thread-local done lists would work though. | |
concurrent instance of your comparison -> "concurrently running instance of your comparison function" | |
Ladislav 4-Jul-2009 [16082] | concurrently running instance of EQUAL? - yes, understood, that would be impossible, but such a thing can be made "atomic/protected", can't it? |
BrianH 4-Jul-2009 [16083] | No. |
older newer | first last |