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

World: r3wp

[Core] Discuss core issues

Tomc
13-Feb-2009
[12398x2]
positions get messed up if and only if the end points of the sub 
range are shuffled in the sort ...
and as their index can be known  beefore hand they can be reset if 
needed. i think
BrianH
13-Feb-2009
[12400]
No, positions get messed up if the length of the data series *anywhere 
before the position* changes. The only datatype this is not true 
for is list!, which is not future compatible.
Tomc
13-Feb-2009
[12401]
but reordering should not change a length
Steeve
13-Feb-2009
[12402x2]
but if the sort on the default data block is applied with a skip 
size equal to your span, then positions are not messed up, is that 
what you mean ?
in that case, it's right
BrianH
13-Feb-2009
[12404]
Reordering will change the length of the portion of the series before 
the moved segments, depending on where they are moved.
Steeve
13-Feb-2009
[12405]
but not if he's sorting data with a skip size equal to the span
BrianH
13-Feb-2009
[12406]
However, sorting the index won't change any of the references that 
the index is pointing to, because the underlying data doesn't change. 
Once you are done sorting and manipulating your index you can commit 
the changes, which means building new data from the index references.
Tomc
13-Feb-2009
[12407x2]
all movement between (and including ) two reffrences stays between 
those same two reffrences
and yes the span (# of columns) is the same  for sorting and skipping
Steeve
13-Feb-2009
[12409]
so no prob, if you don't insert or remove data
BrianH
13-Feb-2009
[12410]
Right. I am more concerned with movement that happens *before both* 
of the two references. That is what can mess up positions.
Tomc
13-Feb-2009
[12411x3]
the initial offset  (which column)  the sort is on changes, but that 
is 
sort/skip/compare/part  ref1 span   column  ref2

Brian's concern is what does this sort do to ref5 and ref 6  position. 
are they still valid.

time to experiment
as this is building a tree, structure later operations always occur 
strictly within earlier operation boundaries
thanks Brian and Steeve. good night
BrianH
13-Feb-2009
[12414]
Good night.
TomBon
19-Feb-2009
[12415x2]
how can this avoided?


does a object! defined within a object! (embedded) breaks with the 
clone/ingherit rule?

calling a function within a object! which e.g. changing a value within 
the embedded object!
changing the parent AND the child object!.

template: make object! [
	obj-in-obj: 	make object! [a: make integer! 0]
	b: 		make integer! 0
	c: func [val] [
		obj-in-obj/a:   val
		b:		val
	]
]  

wcopy: make template []
probe template
probe wcopy
wcopy/c 1000
probe template
probe wcopy

what I am doing wrong here?
and is there any easy way to clear a object at once
without resetting every single variable in the object
I have a big loop (20.000+) which fills many objects with datas.
the objects contains also functions writing and calculating
data within other objects (all within a global context/object). 

each loop is a new run, so I need a new or cleared set of objects 

for every loop. looks like cloning doesn't work for me (see above). 

I could reset every single value, but this will cost me a day minimum.

do I overseen some simple solution here?
[unknown: 5]
19-Feb-2009
[12417]
Not sure what your trying to do but in your function change the object 
reference to self such as:

self/obj-in-obj/a:

see if that makes a difference
sqlab
19-Feb-2009
[12418]
Why you do not make your template just an unevaluated block and then 
you always generate a new object or you never change your template, 
just the descendants ?
DideC
19-Feb-2009
[12419x2]
Its by design : subojbect are not copied by 'make. All R2 VID is 
build on this concept (shared objects).
You need a 'make-deep function that (recursively ?) digg into the 
copied object and copy each subobject it find. I'm sure people arround 
have one in their HD (not me).
TomBon
19-Feb-2009
[12421x3]
paul, makes no difference..sqlab, wrap the object into a unevaluated 
block?
DideC, yes I guessed that. thx
a copy/deep second or third object! doesn't work either.
[unknown: 5]
19-Feb-2009
[12424]
Have you considered using a construct?
TomBon
19-Feb-2009
[12425x2]
paul, I never used construct. can it serve nested constructs also?
will take a look into the docs about it...
Graham
19-Feb-2009
[12427]
does this work?

create-template: func [ d [integer!]
] [
	make object! [
		obj-in-obj: 	make object! [a: make integer! d]
		b: 		make integer! 0
		c: func [val] [
			obj-in-obj/a:   val
			b:		val
		]
	]
]

a: create-template 0
b: create-template 1000
probe a
probe b
b/c 3000
probe a 
probe b
[unknown: 5]
19-Feb-2009
[12428x2]
TomBon, here is the construct docs http://www.rebol.com/docs/changes.html#section-4.1
TomBon, here is the purpose of a construct:

>> ct: construct [int: (1 + 1)]
>> ct/int
== (1 + 1)
>> do ct/int
== 2
>>


Notice that it doesn't automatically evaluate /int as an object would 
do.
TomBon
19-Feb-2009
[12430x2]
YES! thx a lot graham and paul. it works.
yepp, just made a check with real data. works fine. again thx for 
help...
Graham
19-Feb-2009
[12432]
Now, you have to tell us why it works :)
TomBon
19-Feb-2009
[12433]
you have read my mind graham :-) but to be honest I have no idea. 
does the function preserve the scope?
Graham
19-Feb-2009
[12434x2]
I have no idea :)
Where is the parent object now?
TomBon
19-Feb-2009
[12436]
:-)) well sounds thrustfull to built a comercial software on that 
;-)
Graham
19-Feb-2009
[12437]
I presume it's recreated anew each time the create-template runs
TomBon
19-Feb-2009
[12438]
encapsulated within the function space?
Graham
19-Feb-2009
[12439x2]
You still can't clone from the objects it creates ...  ie. e: make 
a [] has the same problems
the parent object is an unevaluated block
TomBon
19-Feb-2009
[12441]
do you think this solution is stable?
Graham
19-Feb-2009
[12442x2]
it doesn't exist as an object.
so, this is sqlabs solution
TomBon
19-Feb-2009
[12444x2]
the object! will be a central part for the lib I am currently building.
wow, fractal programming at it's best
Graham
19-Feb-2009
[12446]
sure it's stable.
TomBon
19-Feb-2009
[12447]
cool