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

World: r3wp

[!REBOL3-OLD1]

BrianH
4-Jul-2009
[15995x2]
It's a recent bug fix. Wait, isn't STRICT-EQUAL? supposed to be EQUIVALENT? 
plus a datatype check? Then if EQUIVALENT? already does zone math 
I vote that STRICT-EQUAL? do zone math and SAME? do precise equivalence.
Wait again, == also does case checking. Does EQUIVALENT? do case 
checking?
Ladislav
4-Jul-2009
[15997x2]
Equivalent?: ignores datatype differences, alias distinctions, character 
case differences
so, more differences between Strict-equal? and Equivalent?
BrianH
4-Jul-2009
[15999]
Then this seems like a good add, unless it is reserved for =?
Ladislav
4-Jul-2009
[16000x2]
you mean to add the distinction of timezone to Strict-equal? - yes 
looks natural
t/zone = none - how did you get that?
BrianH
4-Jul-2009
[16002]
Yeah. (Bad hand, bad keyboard day)
Ladislav
4-Jul-2009
[16003x2]
OK, *adding the timezone distinction to Strict-equal?*
BTW, I should probably put the tests away from the main article, 
otherwise it is quite unmanageable, what do you think?
BrianH
4-Jul-2009
[16005x2]
Oh, the t/zone is really d/zone - it's a date! thing, recently fixed.
Please moo their own page.
Ladislav
4-Jul-2009
[16007]
yes, but still, it is not none, but 0:00
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)