World: r3wp
[Core] Discuss core issues
older newer | first last |
Henrik 23-Jan-2011 [886] | one factor that makes me think this is deep, is because it doesn't occur until the main window has been opened. |
BrianH 23-Jan-2011 [887] | That's deep even by native bug standards. |
Henrik 23-Jan-2011 [888] | I saved the offending data to disk, but am not sure how helpful that is. |
BrianH 23-Jan-2011 [889] | You can go through the steps with the data manually, and with different R2 versions. Anything unexpected will be a clue. |
Henrik 23-Jan-2011 [890] | true, however at this time, it's going to be very time consuming. |
Robert 23-Jan-2011 [891] | It shouldn't be to hard to use 2.7.8 in our setup and switch back and forth between both. We can take a look at it tomorrow. |
DideC 8-Feb-2011 [892x2] | I'm still stuck by binding thing sometimes ! Given the following code, how can I load the object and get back the correct binding ? |
Rebol [] make-obj: func [ "Créé un objet en sauvant son nom dedans." 'name "Nom de l'objet à créer." obj "Objet de base à instancier." spec "extension de l'objet de base." ] [ set name make obj append reduce [to-set-word 'obj-name to-string name] spec ] save-obj: func [ "Sauvegarde un objet selon son propre nom." 'obj "Objet à sauvegarder." /local name ] [ name: any [all [word? obj object? get obj get in get obj 'obj-name] join "objet" random 10000] save/all to-file join name ".r" get obj ] load-obj: func [ "Recharge un objet et l'intancie selon son propre nom s'il en a un." file "Nom du fichier à charger." /local obj ] [ if exists? file [ obj: load file probe bind next first obj obj probe get in obj 'list all [in obj 'obj-name set to-word get in obj 'obj-name obj] ] obj ] task: make object! [ list: copy [] add: funct [t [block!]] [ append list t ] save: does [ save-obj self ] run: does [ do list ] ] make-obj task1 task [] task1/add [a: 0 a: a + 1] task1/add [print a] task1/run task1/save task1: none load-obj %task1.r task1/run | |
Dockimbel 8-Feb-2011 [894] | Try by replacing SAVE/ALL by SAVE and LOAD FILE by DO LOAD FILE. |
DideC 8-Feb-2011 [895x2] | OK, thanks : it works. Now : why does save/all not work ? |
In other words, how to get back a functionnal object from a serialized form (save/all) ? | |
Dockimbel 8-Feb-2011 [897x3] | I'm not sure it's possible because the literal form for object's functions (#[function! ...]) make them evaluated before the object, so the binding process might fail in that case. |
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 |
older newer | first last |