World: r3wp
[Core] Discuss core issues
older newer | first last |
[unknown: 5] 29-Apr-2008 [10401] | so really you would always want the second value to be word: none correct? |
BrianH 29-Apr-2008 [10402x2] | It's an evaluation trick. It evaluates two expressions and returns the value of the first. You can do your cleanup in the second expression. If your cleanup is more complex, put it in a paren. The value returned by the second expression is taken and ignored. |
The second expression clond be a close statement, for instance. | |
[unknown: 5] 29-Apr-2008 [10404x2] | So the get/any is just to ensure that a pointer has been established then right? |
That might not sound correct to you but I think I know why you did that. | |
BrianH 29-Apr-2008 [10406] | It is just there to pass along the first value. |
[unknown: 5] 29-Apr-2008 [10407x2] | Exactly - ok got ya. |
So this would be used as your primary evaluator not as a secondary evaluator called just to do cleanup. | |
BrianH 29-Apr-2008 [10409] | ? Sure, if I understand you correctly. |
[unknown: 5] 29-Apr-2008 [10410] | It's alright I get it now. I was thinking this function was more complex than it is. |
BrianH 29-Apr-2008 [10411] | Here's another example of its use from 2.7.6: first+: func [ {Return FIRST of series, and increment the series index.} [catch] 'word [word!] "Word must be a series." ][ throw-on-error [also pick get word 1 set word next get word] ] |
[unknown: 5] 29-Apr-2008 [10412] | yeah I recall seeing that one. |
[unknown: 5] 1-May-2008 [10413x2] | Is there anyway in REBOL2.7.x to force an immediate garbage collection? Just invoking recycle doesn't seem to do it. |
The invoking of it does work sometimes so I assume there is some type of timing algorithm at play. | |
Gregg 2-May-2008 [10415x2] | What, specifically, do you want to GC that isn't being GC'd when you think it should? |
Or, rather, why do you need to GC something immediately? | |
btiffin 2-May-2008 [10417] | Paul; It's all pretty much voodoo to me, but the few times I care, I start with http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=free-mem.r |
[unknown: 5] 2-May-2008 [10418x2] | Gregg, I was just under the impression we had that kind of control. I'm hoping your question is confirmation that we don't so at least I'm not missing something. |
Yeah brian. I have seen that free-mem function in the past and obviously, it is just setting a word to none and calling recycle. But when the recycle is invoked we don't "see" the clean-up immediately. In other words the GC doesn't immediately respond. This might be a good design but I would have hoped that when we wanted to we could immediately "see" the results of the free memory instead waiting for GC to run the task when it decides to. | |
Gregg 2-May-2008 [10420x2] | AFAIK we don't have that kind of control Paul. The best you can do is make sure the things you want to release are set to NONE and do a RECYCLE. |
Make sure things aren't referenced that is. | |
Henrik 2-May-2008 [10422] | use fewer locals and reuse global series if possible |
[unknown: 5] 2-May-2008 [10423] | Thanks Gregg and Henrik. At least I know I should expect to "see" an immediate release of the memory by the REBOL process. I just wanted to make sure I wasn't missing some REBOL magic somewhere. |
Gabriele 2-May-2008 [10424] | the GC makes the memory available again to rebol, not necessarily the OS. |
[unknown: 5] 2-May-2008 [10425] | Ahhh, thanks Gabriele. What about the OS? - can we return that freed memory to the OS instead? |
Henrik 3-May-2008 [10426x2] | should any object not drop its bindings using this: load mold/all object ? |
ah, load mold object solved it. | |
Gabriele 3-May-2008 [10428] | i don't think there is any way to force rebol to return the memory to the OS, and I don't think there's any need either, but that depends on the OS i guess. |
TimW 6-May-2008 [10429] | I looked around a bit and couldn't really find a good solution. Is there an easy way to reorder a block that's not sorting it - To just move one element. Say my-block: [a b c d e] Is there a function to just move c to the front of the block, or to push it to the back? |
PeterWood 6-May-2008 [10430x2] | This won't be the most elegant solution that you'll come across but may get you started: |
>> move-element: func [ [ blok [block!] [ element [ /to-start [ /to-end [ ][ [ either find blok element [ [ either to-end [ [ head insert tail remove find blok element element [ ][ [ head insert head remove find blok element element [ ] [ ][ [ blok [ ] [ ] >> blk: [a b c d e] == [a b c d e] >> move-element/to-start blk 'c == [c a b d e] >> move-element/to-end blk 'c == [a b d e c] >> move-element/to-end blk 'g == [a b d e c] | |
Pekr 6-May-2008 [10432] | wasn't 'move backported to 2.7? |
PeterWood 6-May-2008 [10433x2] | >> move-element: func [ [ blok [block!] [ element [ /to-start [ /to-end [ ][ [ either find blok element [ [ either to-end [ [ head insert tail remove find blok element element [ ][ [ head insert head remove find blok element element [ ] [ ][ [ blok [ ] [ ] >> blk: [a b c d e] == [a b c d e] >> move-element/to-start blk 'c == [c a b d e ] >> move-element/to-end blk 'c == [a b d e c] >> move-element/to-end blk 'g == [a b d e c] |
I've just checked and move is in Core 2.7.6 | |
sqlab 6-May-2008 [10435] | I was always expecting that I could read lines with user-defined line terminators. But unfortunately it adds them just to the already internally defined line terminators. I see this either as a bug in the handling of read/lines/with or as a ambiguous documentation. |
Gregg 6-May-2008 [10436] | I don't think I've ever used it, so it may be something that hasn't been tested enough. If you can create a small example and post it to RAMBO, that would be great. |
BrianH 6-May-2008 [10437] | PeterWood, you should definitely try MOVE. We were very careful to avoid the aliasing and overlap issues that often happen with move functions; getting it right the first time was the whole point of its inclusion. :) |
TimW 6-May-2008 [10438x2] | Thanks. The move function is nice. Does it have anyway to specify what to move? Because with my-block: [a b c d e], moving c to the front involves my-block: skip my-block 2 |
move/to my-block 1 my-block: head my-block | |
BrianH 6-May-2008 [10440x3] | >> head move/to at [a b c d e] 3 1 == [c a b d e] |
It's those aliasing issues. We realized that specifying any other offset than the current one as the source led to a lot of errors in the corner cases. It was tricky to limit the features of the function to just those that could be used safely. | |
Fortunately you can still use AT, SKIP and HEAD if you need to :) | |
TimW 7-May-2008 [10443] | Thanks! using 'at is very nice. I appreciate it. |
Geomol 7-May-2008 [10444] | What's the best way to produce random passwords? I have an algorithm, that use RANDOM. I figured, I would use seed to start the random generator like this: random/seed to decimal! now/time/precise to be sure, it starts in the most random way. In theory this will give the same result, if the routine is called two times right after each other, and the time didn't evolve meantime. Maybe I shouldn't use seed? How does REBOL start its random generator, when REBOL launch? What does RANDOM/secure do? |
Pekr 7-May-2008 [10445] | I used the same and added random copy/part to it :-) |
Sunanda 7-May-2008 [10446] | We take several steps in various bits of REBOL.org system code to produce unique identifiers. The code factors in not just now/time/precise but also things like: -- user name -- length? mold system -- incoming IP address But, ultimately, you cannot *guarantee* not to get an id clash that way. So (in cases where clashes matter), we also create a temporary file, id.tmp .... If that already exists, we generate a fresh id until we get a unique one. In the case of REBOL.org, the id.tmp files are deleted weekly, as a week old clash is not important. |
Gabriele 7-May-2008 [10447] | Geomol, use RANDOM/SEED NOW/PRECISE (no /time and no to decimal!) |
Geomol 7-May-2008 [10448] | Gabriele, I'm afraid, that's not good enough. Try this: >> loop 10 [random/seed now/precise print random 100] 28 28 28 28 28 28 28 28 28 28 While if I do it my way, I get this: >> loop 10 [random/seed to decimal! now/time/precise print random 100] 75 53 21 3 2 57 54 69 74 15 (I did it under OS X with version 2.7.6) |
Sunanda 7-May-2008 [10449] | You could drop the seeding and just use random/secure loop 10 [prin [random/secure 100 " "]] 99 22 67 18 31 6 54 80 94 24 |
Geomol 7-May-2008 [10450] | What do random/secure do precisely? Does anyone know? |
older newer | first last |