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

World: r3wp

[Core] Discuss core issues

Henrik
29-Dec-2010
[872]
Does R2/Forward contain fixes to TO-LOCAL-FILE? There are some rather 
significant differences in functionality between the R2 and R3 version.
BrianH
29-Dec-2010
[873x3]
As a rule, R2/Forward hasn't had any changes to native functions 
in R2, mostly for performance and compatibility reasons. It is intended 
to have an extended version later that attempts to backport as many 
native changes as possible, but that won't be the default because 
it would break a lot of the same R2 code that R3 breaks.
However, TO-LOCAL-FILE? and TO-REBOL-FILE? aren't really that fundamental, 
and were originally written in REBOL, so it might be OK to change 
them if it can be done without breaking code. What are the specific 
differences you have found between the R3 and R2 versions?
Got it: the /full option.
Henrik
29-Dec-2010
[876]
R2:

>> to-local-file to-file "/test"
== "t:\st"

R3:

>> to-local-file to-file "/test"
== "\\test"
BrianH
29-Dec-2010
[877]
Oh, nice. Yes, that's worth doing, and fits within the rules. For 
that matter, it's worth adding to the R2 bug list.
Gregg
29-Dec-2010
[878]
I agree on POKE supporting unset! to match CHANGE and INSERT.
BrianH
30-Dec-2010
[879]
Henrik, that fix is scheduled for 2.7.8, but not the /full option.
Maxim
13-Jan-2011
[880]
yay... the fact that we couldn't support writing out UNC paths easily 
has bitten me at a high-profile client in the past :-)

nice to have that fixed.
BrianH
13-Jan-2011
[881]
It was scheduled for 2.7.8 but didn't make the deadline. So now it's 
still pending.
Henrik
23-Jan-2011
[882x2]
I'm able to consistently produce this in 2.7.7:

---------------------------
REBOL Error
---------------------------
REBOL Internal Error: Invalid series width 1 was 16 (type 39)

Program terminated abnormally.
This should never happen.
Contact www.REBOL.com with details.
---------------------------
OK   
---------------------------


Will need to dig a little. Not sure if it's an encryption part, debase 
part or what it is yet, but it occurs, when loading enbased, encrypted 
data.
ok.... it apparently happens when LOADing certain DECLOAKed data, 
but only under specific circumstances.
BrianH
23-Jan-2011
[884]
Does it happen in 2.7.8?
Henrik
23-Jan-2011
[885x2]
I am unable to test this, as 2.7.7 is heavily integrated into RM 
Asset's build system for the NLPP program
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) ?