« first day (1869 days earlier)      last day (1911 days later) » 

12:02 AM
@kealist The EAN128 question?
 
12:34 AM
@giuliolunati I don't know about custom MOLD-ing; that may be a system-level service only. But custom FORM-ing is definitely something to support.
 
1:03 AM
@HostileFork Regarding the map bug
 
@kealist Oh, answer of what to do about it?
Avoid map! if you can't recompile. :-/ It's pretty much entirely broken. When @ShixinZeng adds it to Atronix's branch then it should take care of at least that problem.
I honestly am not entirely certain how the MAP! works (w.r.t. its hashing and collisions), because it does something a bit weird that is not explained. It may have a rationale to it that has something to do with working due to prime numbers and some kind of worst-case scenario decay I've not seen but is a known implementation trick.
Basically it has a set of key value pairs (REBVAL) in an array [k1 v1 k2 v2 k3 v3 ...] and then on the side it has a larger array of index numbers (unsigned integers) of a prime numbered length, which points into the index numbers. It uses a hash of the key to look it up. So HASH(k2) would index into the hashes to some position N, and when you look in bucket N you'd find the number 3 for the index of K2, for instance.
The thing I don't understand is what happens when you HASH(kX) and HASH(kY) and they hit the same spot. It can't hold both indices. So what it does is it checks to see if it has a match (only one would, the other would not) and if not a match, it uses a skip value to go to a next bucket and repeats the process.
The thing I'm not sure about is how you don't get false negatives...even if the skip count is done in such a way that it can in a worst case scenario visit all the spots, what stops one hash from disrupting another hash's position?
@kealist If you wished to look into writing a little hash table stress test just to see if the patched Ren-C one ever has false negatives or false positives or anything for lots of random numbers, that would be helpful...
I can't say it doesn't work but I don't see with great confidence why it "obviously should work"
 
 
1 hour later…
2:23 AM
@kealist Oh, that they deny it. Sorry, they're wrong.
That's fine, and I welcome them to be wrong. Let them try @MarkI's example: union/skip [1 1 2 2 2 2] [] 2. The problem is not constrained to that, and I guess once I find something accessing invalid memory I don't know that I really have the time to go and prove to people who won't read the code and see why it's wrong that it's wrong.
It applies to maps as well, in fact the problem I first hit was on a map in the Red R3 port.
The link in the bug report is to actual source lines, with an actual problem, defining what it is. If that's not enough <shrug>
The same hashing logic is used in the creation of maps as used in UNIQUE, it just passes in 2 as the skip value. My point about UNIQUE/SKIP was that it's not always 2, so it can't be "divide by 2 and add 1"
 
2:53 AM
As for why maps tended to work anyway, I think the mystery of that likely ties into the mystery of why they appear work at all...which is perhaps due to some kind of trick of it decaying into an exhaustive search somehow.
@MarkI Would you mind figuring out how MAP! works, if it works? :-/ See my notes above --^
 
Thanks for the explanation, I will see if I can figure out a way to write a stress test
 
3:15 AM
@kealist Great, that would be useful.
 
We had a baby about a month ago, so the last few months (or 6) have been pretty busy
 
@kealist I imagine so. Belated congratulations... (Assuming that's what you wanted to happen... :-P)
 
@HostileFork Thank you. Yes it is good :)
 
 
1 hour later…
4:37 AM
I have been thinking that either function needs a <keywords> refinement or there needs to be a dialect generator. The idea is that you list the keywords and some help about them in the spec, but then also you get a /keywords refinement that can take a map and let your function remap the keywords.
Then a keyword-of function, or something of that nature, which is local to your function and uses that map (if there is a map). Basically, if you don't pass in /keywords then the keyword-of function gets defined locally as just returning the word you pass in...so fast. In fact, we need that operation defined as a fast native...a single arity function that just gives back what you give it.
Naming suggestions welcome. It could be something like "passthru" but that's not very good.
parse: function [
    {Parses a string or block series according to grammar rules.}
    input [any-series!] "Input series to parse"
    rules [block! string! none!] "Rules to parse by"
    <keywords>
    any [rule {rule to continue through}]
        {Matches a rule any number of times, including 0}
    ...
][
...
]
parse/keywords "aaa" [alguna "a"] make map! [any alguna]
So then, inside of this hypothetical mezzanine-level parse thing, it would have keyword-of defined so that keyword-of 'alguna would come back with any. So instead of saying item = 'any it would say item = keyword-of 'any, and alguna would count. The el-cheapo trick being that keyword-of would be bound to this thing that blits right by and doesn't even look at a map if the /keywords refinement is not used.
>> source parse
== make function! [[... /keywords keywords-map [map!]] [
    keyword-of: either not keywords [keyword-of: :passthru] [
        func [word [any-word!]] [any [:keywords-map/:word word]]
    ]
    ...
]
 
5:07 AM
@RebolBot
foo: make object! [a: 1020 b: 304]
pick foo 2
 
; Brought to you by: try.rebol.nl
; rebol.com/r3/docs/errors/script-expect-arg.html
    *** ERROR
** Script error: pick does not allow object! for its aggregate argument
** Where:
** Near: try load/all join %/users/try-REBOL/data/ system/script/args...
 
@RebolBot
foo: make object! [a: 0 b: 0]
set foo [1020 304]
probe foo
 
; Brought to you by: try.rebol.nl
make object! [
    a: 1020
    b: 304
]
== RESULT is an object of value:
   a               integer!  1020
   b               integer!  304
 
I don't really see the point of disallowing the former if the latter is permitted...either the order of keys in an object is something user-visible or it is not.
It ties the hands of the implementation to allow code to become dependent on the ordering... and I don't think order-dependence in objects is a "great feature"
@redbot
foo: make object! [a: 0 b: 0]
set foo [1020 304]
probe foo
 
; Brought to you by: try.rebol.nl
make object! [
    a: 1020
    b: 304
]
== make object! [
    a: 1020
    b: 304
]
 
5:10 AM
@redbot
foo: make object! [a: 1020 b: 304]
pick foo 2
 
; Brought to you by: try.rebol.nl
*** Script error: pick does not allow object for its series argument
*** Where: pick
*** Stack: do-console all not unset? set do first head reduce do* _execute if all not unset? set do first head reduce do* pick
 
And no one is surprised.
 
Objects have a natural order, the order the members are created in, and this order is preserved by to-block. As far as pick, I'm on the fence.
 
@MarkI If you derive objects then the natural order goes away.
If keys collide then the first one wins, and it's rather arbitrary
It's very APPLY-like, in that when there is a keyed order to work with then falling back on the declaration order and requiring the system to be beholden to it has bad properties.
But if there's going to be an order, and it's going to be user exposed, it should be exposed via pick
No point in bending over backwards to provide the facility and then forcing users to get creative in reinventing pick to do what you tell them is not only okay to do, but that you're willing to muck up degrees of freedom in object implementation to preserve.
If it's a feature, it's a feature. If it's not, don't make it one.
 
5:26 AM
Agreed. IMO pick obj n should macro to select obj pick words-of obj n.
It's even clear why it would be useful with that definition.
And I disagree that the order is arbitrary. It is both predictable and regular.
 
>> (make object! [a: 1 b: 2]) = (make object! [a: 1 b: 2])
 
; Brought to you by: try.rebol.nl
== true
 
>> (make object! [a: 1 b: 2]) = (make object! [b: 2 a: 1])
 
; Brought to you by: try.rebol.nl
== false
 
@MarkI I'm not confident that the general programming public is going to appreciate the genius.
But, it could be, that objects are said to be ordered and maps are not. I dunno.
 
5:35 AM
I do see where you are coming from. I haven't figured maps out yet sorry :(.
 
No rush, but if you can, let me know.
 
Now they're imposing some arbitrary ordering for sure.
 
 
3 hours later…
8:41 AM
posted on December 13, 2015 by Ladislav

[Comment] Another one worth considering: if true 1 + 2 versus case [true 1 + 2]

 
9:01 AM
@HostileFork Seems to me that can work fine. One can search-and-skip until the right key is found (must check at every step) or an empty bucket is found (negative case)
 
@giuliolunati Guess I'd have to watch it and choose the smallest prime above the hash size. Something like 4 elements and a 5 hash, and see how it works out with the skipping to not cycle and still visit all the spots.
Basically put that through a worst case scenario
 
if length-table and skip-step are coprime sure it works fine!
 
@giuliolunati Ah, well there's the word I was looking for.
In number theory, two integers a and b are said to be relatively prime, mutually prime, or coprime (also spelled co-prime) if the only positive integer that evenly divides both of them is 1. That is, the only common positive factor of the two numbers is 1. This is equivalent to their greatest common divisor being 1. The numerator and denominator of a reduced fraction are coprime. In addition to and the notation is sometimes used to indicate that a and b are relatively prime. For example, 14 and 15 are coprime, being commonly divisible by only 1, but 14 and 21 are not, because they are bo...
@guiliolunati If you want to add some notes on why it works to the map then that would help. :-)
So SELF is not going to be the first hidden object field, but it's going to quickly become the most common...which means we're going to see more exercise of the code paths relating to handling of hidden things...
@RebolBot
foo: object [a: 0 b: 0 c: 0]
protect/hide 'foo/c
probe foo
set foo [10 20]
 
9:18 AM
; Brought to you by: try.rebol.nl
; rebol.com/r3/docs/errors/script-hidden.html
    make object! [
    a: 0
    b: 0
]
*** ERROR
** Script error: not allowed - would expose or modify hidden values
** Where: set
** Near: set foo [10 20]
 
There are many places they are not accounted for, so when these hidden SELF fields that are real fields start showing up, expect some speedbumps.
 
 
3 hours later…
12:16 PM
@HostileFork About find-key algorithm in t-map.c: after this line is 0 < skip < len. But len is prime, so is coprime with skip. Here hash index is increased by skip, modulo len. The period after that hash index repeats* is len, because len and skip are coprime. *That can occur only if table is full.
So IMHO Find_Key_Hashed is correct, and never gives false positive or negative.
 
12:30 PM
@giuliolunati post-change :-)
Sounds plausible to me... well if the period of repetition is len then that would work.
We're going to need some kind of new hashing on word symbols because they are going to be pointers instead of integers in a contiguous range...
So the binding table and such will need to be hashing pointers and managing collisions, I don't know if this is a good way to keep going with that or not
 
@HostileFork The period is surely len.
 
1:13 PM
n * skip = 0 (modulo len) -> n * skip = m * len -> skip divides m (because skip and len are coprime) -> m / skip = k (integer) -> n = len * m / skip = len * k -> len divides n
 
 
11 hours later…
11:59 PM
@giuliolunati We can add some version of your comments to the code... I believe you. :-)
 

« first day (1869 days earlier)      last day (1911 days later) »