World: r3wp
[!REBOL3]
older newer | first last |
Geomol 21-May-2011 [8807x2] | Thanks, Ladislav. Good examples! The thing, I missed, was that REBOL has this extra internal data structure to hold symbols (words), I though, just the contexts was used for that. So comparing words (that are not bound to any context) are much faster than comparing strings in REBOL. I see different possibilities, depending on implementation. If a word is changed to the result from a hash calculation, then two different words might give the same result, right? It's unlikely, but it could happen. That's why map datastructures are combined with lists, when two different hash calculations give same result. The other possibility is, that words are changed to pointers pointing to their entry in the map (hash table). Do you know, what of the two, REBOL implement? In other words, could two different words be equal in REBOL? About the strings, then it's possible to do kind of the same with hashing. Lua does that. If you have two different but identical strings (same string content) in Lua, they share the same memory area. Hashing is involved, and I guess, comparing string would be equal fast as comparing words, if REBOL did the same. (unless words are exchanged with the result from the hash calculation, but then two words might be equal) |
After a little testing, it seems, words are changed to a hash result, and REBOL gives an error, if two different words give same result: >> s: "abcdefghijklmn" >> forever [if equal? a: to word! random s b: to word! random s [print [a b]]] ** Internal Error: No more global variable space The error comes really fast. | |
Kaj 21-May-2011 [8809] | Petr, Nightwish? :-) |
Geomol 21-May-2011 [8810x3] | Above test is in R2. |
R3 keeps going and can't be stopped with <Esc>. | |
<Esc> + <Ctrl>-c seem to stop it. | |
Kaj 21-May-2011 [8813x2] | Global variable space should be the special object holding global values in R2. That's not the symbol table, either |
My guess is that it must do more useless binding than R3 | |
Geomol 21-May-2011 [8815] | You're right. to word! put it in system/words, I need to do to block!, I guess. |
Kaj 21-May-2011 [8816] | Maybe to-lit-word works |
Geomol 21-May-2011 [8817] | In R2: s: "abcdefghijklmn" forever [if equal? a: to block! random s b: to block! random s [print [a b]]] rebol-console: line 2: 5658 Floating point exception./rebol --noviewtop A crash. Interesting! :) |
Kaj 21-May-2011 [8818] | Indeed |
Geomol 21-May-2011 [8819] | to lit-words! also put it in system/words in R2. |
Kaj 21-May-2011 [8820x2] | That's probably one of the things optimised away in R3 |
It's such a shame it's stalled | |
onetom 21-May-2011 [8822] | I think, Carl will return soon and he will open source R3. He must have a hard time doing that other job, but probably he will experience the bright side of the open collaboration too. Im expecting him to realize that he can actually help the world effectively if he can unleash the power us, the long time fans of rebol. |
Kaj 21-May-2011 [8823x2] | Don't hold your breath |
John, to keep your mind on the edge of the cliff, did you know about the global series table? :-) | |
Geomol 21-May-2011 [8825] | Not sure, what's that? |
Kaj 21-May-2011 [8826x5] | Quite similar to the global symbols table, the existence of a global series table can be deduced, from the R3 extensions interface |
A series value does not include an index. Only a reference does. So that's one indirection, from a value slot (with an index) to a series value | |
But there must be another indirection, from the series value to the actual storage location of its item slots, because the item storage can't be counted on to stay at the same memory address over garbage collection and callbacks or multitasking, but it must be deduced that the series value can be counted on to stay at the same memory address | |
So there must be a table of series descriptors apart from the actual series content | |
Maybe it doesn't really need to be a global table, but it seems very convenient for the garbage collector | |
Geomol 21-May-2011 [8831] | No, haven't heard of that. |
BrianH 21-May-2011 [8832] | It wouldn't need to be a global table, it could be a heap space dedicated to series descriptors (a typed array in memory). Same purpose, more likely implementation. Precise collectors are often implemented with type-specific heap spaces, since it reduces fragmentation when you don't have a copying or compacting collector - REBOL's collector doesn't move values, supposedly. REBOL could get away with heap spaces for block data, string/binary data, and descriptors (maybe both object and series in the same heap space); there might be more, but adding more can make the memory management more complicated. |
Kaj 21-May-2011 [8833] | I'm not sure how that differs from my description |
BrianH 21-May-2011 [8834] | can't be counted on to stay at the same memory address over garbage collection - as far as I know this has never been demonstrated. The performance characteristics of REBOL's garbage collection are more consistent with mark-and-sweep, and there hasn't been any indication that it compacts or copies. Series reallocation on expansion does copy though. Plus, there is a bunch of indication that R3 isn't yet task-safe and that callbacks can choke on shared data too. Aside from that, your argument's good, and your conclusion more so. |
Kaj 21-May-2011 [8835] | Well, I wouldn't count on it, but indeed, what the extensions documentation specifies is that series can move when they are changed. It's all very vague, but if the collector doesn't compact as you say, it would be restricted to expanding series beyond the internally allocated memory region |
Ladislav 21-May-2011 [8836x5] | time-block? u mean delta-time? I mean TIME-BLOCK: http://www.fm.tul.cz/~ladislav/rebol/timblk.r |
could two different words be equal in REBOL? - in my opinion, that would be a bug | |
(unless intended, using aliasing) | |
heap spaces for block data, string/binary data, - there is absolutely no reason to have different spaces for strings and blocks | |
aha, maybe there is | |
BrianH 22-May-2011 [8841x2] | If you allocate strings only in multiples of 128 bits and aligned the same as blocks, fragmentation wouldn't be a problem if they are allocated in the same space. It would be a waste of resources for strings though, as even a single-char string would take 16 bytes of space. |
Some memory management systems segregate the values by the size, with objects of similar sizes allocated from the same space, to cut down on fragmentation. Large enough objects are sometimes allocated on their own, in a seperate chunk of memory allocated from the OS. I haven't seen any indications that REBOL's memory management does this though. | |
Jerry 24-May-2011 [8843] | Why does SKIP accept LOGIC! and PAIR! as its OFFSET parameter? Thanks. |
Geomol 24-May-2011 [8844] | pair! is for images, I think. |
Jerry 24-May-2011 [8845] | I have the same guess. Geomol |
Geomol 24-May-2011 [8846] | About logic, I guess, it's related to a wish to use PICK with logic argument. It works like this for SKIP: >> skip [a b] true == [a b] >> skip [a b] false == [b] and you can use PICK instead of EITHER sometimes like: value: pick [1 2] b > 1 instead of value: either b > 1 [1] [2] |
Jerry 24-May-2011 [8847] | SKIP with TRUE as its 2nd argument, which made me think it DID skip. SKIP with FALSE as its 2nd argument, which made me think it DIDN'T skip. With your PICK example, now I understand. |
Geomol 24-May-2011 [8848x2] | Yes, the initial imagined behaviour is turned around with logic. :) The PICK method is also faster than the EITHER method, if it's simple values to pick. If you have to reduce the block, the EITHER method is faster, as EITHER already reduce its blocks. |
In R2, you can pick from functions, like: >> pick :to-integer 1 == [value] and it works with true too, but not with false: >> pick :to-integer true == [value] >> pick :to-integer false ** Script Error: Out of range or past end In R3, you can't pick functions like this. | |
Endo 24-May-2011 [8850] | SKIP with LOGIC value seems reverse, because it doesn't convert logic to integer before use it: >> to-integer true == 1 |
Geomol 24-May-2011 [8851] | See Core group! |
Endo 24-May-2011 [8852] | Yep, I saw it. |
Jerry 24-May-2011 [8853] | LENGTH? 'WORD is 4, LENGTH? /WORD is 5 ... not 4. Why? is the heading #"/" in refinement counted? |
Endo 24-May-2011 [8854x2] | I guess it counts / as part of it: >> to-string /WORD == "/WORD" >> to-string 'WORD == "WORD" |
But I don't know if it is a bug or not. | |
Geomol 24-May-2011 [8856] | To be able to type a word of datatype word!, we need lit-word!. Else the word would be evaluated to it's value. So when you write length? 'word , it's the same as length? first [word] To get what you want: length? first ['word] or length? quote 'word |
older newer | first last |