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

World: r3wp

[Core] Discuss core issues

BrianH
29-Apr-2008
[10403]
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?
Sunanda
7-May-2008
[10451]
It claims to be a "cryptographically secure random".
That won't stop clashes though

http://www.rebol.com/docs/words/wrandom.html
Geomol
7-May-2008
[10452]
What I'm after, is a secure way to produce a password, also in a 
webservice, that could be called many times each second. RANDOM/secure 
can produce the same output again and again, as can be seen with 
this:
>> loop 10 [random/seed now/precise prin [random/secure 100 ""]]
61 61 61 61 61 61 61 61 61 61

See the block as the webservice. So here it's not good to use random/seed. 
If I leave out random/seed, what then define the initial state of 
the random generator? I need to know this to figure out, if this 
is a secure way to produce a password or not.