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

World: r3wp

[Core] Discuss core issues

Dockimbel
8-Feb-2011
[898x2]
Using SAVE ensures that you have a list of symbols in unevaluated 
form more suitable for object reconstruction and proper binding.
Anyway, binding information is lost during serialization (MOLD or 
MOLD/ALL), so if you want to get back bindings from serialized code, 
you need to manually ensure that the binding will be reconstructed 
as expected. That's achieved easily in your simple example using 
the SAVE / DO combination, but it can get much more complex in other 
cases and could require a lot of additional code.
DideC
8-Feb-2011
[900x4]
So to resume, serialized form is not suitable for object!.
do load
 does not work with the serialized form (I tried it)?
sorryn o "?" but DOT
Last question, why can't the binding of the save/all form be restored 
by the manual 'bind ?
Dockimbel
8-Feb-2011
[904x2]
do load

 does not work with the serialized form (I tried it)?" I'm not sure 
 to understand what you mean there. SAVE/ALL uses MOLD/ALL to serialize 
 values, so binding information is not preserved. If you want to restore 
 correct binding in a object! serialized using /ALL format, you need 
 to write some code to walk through object's functions body blocks 
 and bind object's words explicitely using BIND.
This would be similar to what MAKE does on an object's spec block! 
but a bit smarter as you need to dive into function! values (MAKE 
doesn't do that AFAICT). You need to see the distinction between 
"unevaluated code" (source form) and "evaluated code" (reduced form) 
to get a clear picture on this issue.
BrianH
8-Feb-2011
[906]
Nested bindings are faked using a procedural process in REBOL. Serialized 
syntax is declarative, and there isn't a reference to the bindings 
in that syntax. It would be possible to make a serialized syntax 
that includes binding references, and the proposal to do that is 
called Rebin.
Rebolek
9-Feb-2011
[907]
Is there sort function (comparator) for no sorting, so this will 
be TRUE ?

block = sort/compare copy block :comparator
Sunanda
9-Feb-2011
[908x2]
The only one I can think of only works if the entries in _block_ 
are unique:

     sort/compare copy block func [a b][return (index? find block a) < 
     index? find block b]
This may work too:
  sort/compare/skip block func [a b][return true] length? block
ChristianE
9-Feb-2011
[910x2]
sort/compare [t r y t h 1 s] func [a b] [0]
If you want SORT to be stable, return -1, 0, 1 instead of just TRUE 
and FALSE.
Rebolek
9-Feb-2011
[912x2]
Doesn't seem to work in R3.
>> sort/compare [t r y t h 1 s] func [a b] [0]
== [r y t h 1 s t]
ChristianE
9-Feb-2011
[914x2]
It's not supposed to work in R3.
R3 currently has no stable sort. At least not on all platforms.
Rebolek
9-Feb-2011
[916]
Ah, ok.
Andreas
9-Feb-2011
[917]
(Which is http://issue.cc/r3/1152.)
Sunanda
9-Feb-2011
[918]
This does a null sort in R2 and R3.....but it requires the func to 
know the name of the block being sorted:

    sort/compare block func [a b /local c] [c: [] if 0 = length? c [append 
    c block]  block: copy c 0]
Pekr
9-Feb-2011
[919]
sort is mostly useless anyway - it will not work with unicoded alphabets 
anyway, no?
Sunanda
9-Feb-2011
[920]
R2 needed some heroics for other collating sequences. Not tried this 
sort of thing in R3 yet.
   http://www.rebol.org/ml-display-message.r?m=rmlMWWJ
DideC
11-Feb-2011
[921]
Argh! Does one remember how to convert integer! to its binary equivalent 
and the opposite, in R2 and in R3 (it's different IIRC) ?
Sunanda
11-Feb-2011
[922]
R2 way is to use to-hex
    to-hex 100
    == #00000064
DideC
11-Feb-2011
[923x3]
Yes, but issue! are not binary!
I need to make some binary mask with some integer value like :
	var: random 99999999
	res: var and #{00ff0000}
OK. Find a solution.

to-integer #{00ff0000} give me an integer, so I will make some "constant" 
values from the binary I need and will make the AND between integers.
Ladislav
11-Feb-2011
[926x2]
>> to integer! binary: debase/base to-hex integer: 11 16
== 11
(not very convenient, I admit)
DideC
11-Feb-2011
[928]
LoL
Ladislav
11-Feb-2011
[929]
In R3 is is much more comfortable
Geomol
11-Feb-2011
[930]
Another option:

>> do http://www.fys.ku.dk/~niclasen/rebol/libs/bit.r
>> enhex 100 
== #{00000064}
GrahamC
12-Feb-2011
[931x4]
I want to block all of eastern europe ( sorry guys ) from my sites 
...
now vbulletin only allows blocking by ip address eg. 1.2.3.*
but the country blocks appear like this 

# Country: RUSSIAN FEDERATION
# ISO Code: RU
# Total Networks: 4,256
# Total Subnets:  35,139,848
2.60.0.0/255.252.0.0
2.92.0.0/255.252.0.0
31.28.0.0/255.255.224.0
46.0.0.0/255.255.0.0
46.3.0.0/255.255.0.0
is there some code I can use to transform the bottom into the top?
should I just simply replace the first occurence of a 0 on the left 
with a * ?
Andreas
12-Feb-2011
[935]
depends on the accuracy you need
GrahamC
12-Feb-2011
[936x2]
I don't need accuracy!
I just to block every spammer that lives in Eastern Europe
Andreas
12-Feb-2011
[938]
then replace every non-255 occurence with * :)
GrahamC
12-Feb-2011
[939]
eh?

2.60.0.0 => * ??
Andreas
12-Feb-2011
[940x2]
from the mask :)
this will match several million false positives too, but well :)
GrahamC
12-Feb-2011
[942x2]
vbulletin doesn't use masks
ok, so where there isn't a 255 in the mask, then replace the same 
point in the ip address with a *
Andreas
12-Feb-2011
[944x3]
2.60.0.0/255.252.0.0 is 2.60.0.0/22
2.60.*.* will match less than 2.60.0.0/22
2.*.*.* will match more than 2.60.0.0/22
GrahamC
12-Feb-2011
[947]
well, I think I would use 2.*