r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3-OLD1]

BrianH
4-Jul-2009
[16008]
moo -> move the tests to. Bad AltMe as well.
Ladislav
4-Jul-2009
[16009]
OK
BrianH
4-Jul-2009
[16010x2]
You're right:
>> d: 12-Jan-2000
== 12-Jan-2000
>> d/zone
== none
>> d: 12-Jan-2000/1:00
== 12-Jan-2000/1:00
>> d/zone
== 0:00
Current build, don't know about after Carl's current changes.
Ladislav
4-Jul-2009
[16012x2]
d/zone  = none is related to the d/time = none, yes
("pure" date)
BrianH
4-Jul-2009
[16014]
So apparently the time zone is never none, but the whole time in 
date! may be none.
Ladislav
4-Jul-2009
[16015]
this is discerned by Equivalent? already, otherwise it would not 
be transitive
BrianH
4-Jul-2009
[16016]
Ladislav, check bug#1049 - I added a new comment. We need to discuss 
this.
Ladislav
4-Jul-2009
[16017x3]
this is already done by MOLD, so it is present
(I mean the marking)
...as well as collect-words, etc....
BrianH
4-Jul-2009
[16020x2]
Mold does cycle detectionn, but not cycle comparison. Mold gives 
up when it detects a cycle.
EQUAL? would have to detect whether the cycle was the equivalent 
reference to the cycles of the other block.
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