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

World: r3wp

[Core] Discuss core issues

Rebolek
9-Dec-2010
[622]
I'm afraid this will not help very much if I want to switch second 
and fifth element.
Henrik
9-Dec-2010
[623]
MOVE
Rebolek
9-Dec-2010
[624]
thanks!
Henrik
9-Dec-2010
[625]
:-)
BrianH
9-Dec-2010
[626x2]
Also SWAP.
SWAP is designed for just this situation, and has been backported 
to R2 as well. Here is the source if you have an old R2 version:
swap: func [
    "Swaps elements of a series. (Modifies)"
    series1 [series!]
    series2 [series!]
][
    unless any [empty? series1 empty? series2] [

        poke series1 1 also pick series2 1 poke series2 1 pick series1 1
    ]
    series1
]
Rebolek
9-Dec-2010
[628]
SWAP is not mezanine, better!
BrianH
9-Dec-2010
[629]
In R3, true :)
Rebolek
9-Dec-2010
[630]
Ah, sorry, I was looking for R3 sollution.
BrianH
9-Dec-2010
[631x3]
Note that the unless guard above is compatible with the R3 version. 
If either series is empty or at its tail at that position, it's a 
noop, silently.
So watch out.
Watch out for this limit in R3 too (which I forgot to backport):
>> swap a: "a" b: %b
** Script error: values must be of the same type
** Where: swap
** Near: swap a: "a" b: %b
Rebolek
9-Dec-2010
[634]
I need it for blocks that has been sanitized before, so no problem 
here.
BrianH
9-Dec-2010
[635]
As far as I can tell, the single type restriction is so the implementation 
of the action in the various datatypes can be simplified. I am interested 
to see how well SWAP works for gobs though. Can you test this and 
see if there are bugs?
Rebolek
9-Dec-2010
[636]
Yeah, I will. But I expect problems, gob! series support is very 
limited.
BrianH
9-Dec-2010
[637]
There shouldn't be any problems with this particular operation being 
defined, but I haven't done much bug testing since I don't need any 
graphics support most of the time. All I do is core.
Rebolek
9-Dec-2010
[638x2]
As expected:

>> swap g next g
** Script error: cannot use swap on gob! value
** Where: swap
** Near: swap g next g
this IS core stuff. i haven't called view ;)
BrianH
9-Dec-2010
[640x2]
Does it work between different gobs? Note: It would only work with 
gobs that have subgobs, in theory.
If it doesn't, this needs a ticket. There are other similar gob bugs 
(CHANGE comes to mind).
Rebolek
9-Dec-2010
[642]
Does it work between different gobs?

 - no, it doesn't work between two gobs and it doesn't work for one 
 gob (with sub gobs).
BrianH
9-Dec-2010
[643]
Then we need a ticket for that. I would think that there would be 
some GUI reasons for doing SWAP, though more for doing MOVE.
Steeve
9-Dec-2010
[644]
Well it' s a bad example, because
>> swap g next g
is easly performed with:
>> insert g g/2
:-)
Ladislav
9-Dec-2010
[645]
??

>> g: [a b]
== [a b]
>> insert g g/2
== [a b]
>> g
== [b a b]
BrianH
9-Dec-2010
[646]
I just checked, and all of the functions called by MOVE are compatible 
with gobs. If they behave in a similar way then we can add gob support 
to MOVE.
Steeve
9-Dec-2010
[647]
working with gobs only
Ladislav
9-Dec-2010
[648]
working with gobs only
 - isn't it a bug, then?
Steeve
9-Dec-2010
[649x4]
No it's a feature
A Gob can only have one parent at a time.
when you insert a gob already connected somewhere, it's automacly 
removed from the old place
Great feature
Rebolek
9-Dec-2010
[653x3]
hmmm
Yes, I agree
Hm, I see that gob! now supports CHANGE and POKE, good news.
BrianH
9-Dec-2010
[656]
CHANGE doesn't work: http://curecode.org/rebol3/ticket.rsp?id=1789
Rebolek
9-Dec-2010
[657]
You're right. I remember it was throwing error, so I thought it's 
ok now with my quick test.
GrahamC
9-Dec-2010
[658]
What's the technical explanation for this question/answer ?  http://synapse-ehr.com/forums/showthread.php?151-Help-with-Script-error-Cannot-use-path-on-none!

Is it the way Rebol evaluates as it builds functions?
BrianH
9-Dec-2010
[659x2]
It looks like the code disconnects from the database and then tries 
to save to it without reconnecting. Beyond that I can't tell without 
knowing at which stage of the code the error is triggered.
But it looks like the error is triggered before the SQL call, so 
it looks like either the db or counter variables are none.
GrahamC
9-Dec-2010
[661x3]
to me it looks like the code is breaking when first executed
so, it creates an empty db, so db/1 will be an empty block
My question is .. what does rebol do when it builds a function from 
the function definition
BrianH
9-Dec-2010
[664]
There is nothing special there related to the function definition. 
The 'db and 'counter vars are global. It looks like the initial
    db: SQL "select * from customer" 
call is failing, and 'db is set to none. Test for that.
GrahamC
9-Dec-2010
[665]
If that were the case, the 'layout would fail ...
BrianH
9-Dec-2010
[666]
When are the paths in the layout evaluated? The only part I don't 
know is the View part.
GrahamC
9-Dec-2010
[667]
Immediately
BrianH
9-Dec-2010
[668x2]
In that error there are only 3 path roots that could be none: db, 
db/:counter and FN. If the db is empty then db/:counter would be 
invalid even in the layout. That leaves FN.
This seems like a job for PROBE.
GrahamC
9-Dec-2010
[670x2]
If ''layout completes, then FN will be a VID field object
so this suggests to me that db = [ ]