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

World: r3wp

[Core] Discuss core issues

Endo
12-Oct-2011
[2420]
If it supports those actions, then it should be everywhere:

SKIP, ADD, DIV, NEXT, NEGATIVE, AND etc.. then it leads a overhead.
Geomol
12-Oct-2011
[2421]
I would guess, the code is different for doing next string, next 
block and next port.
Endo
12-Oct-2011
[2422]
I like the idea, but it looks it needs using too much GET value in 
all the actions above.
Geomol
12-Oct-2011
[2423x4]
Yeah, and some may argue, it's less readable with call-by-word options. 
But some probably also finds it strange, that NEXT string doesn't 
alter the string, while LOWERCASE string does.
A lot of things like

var: var + something	; or
var: add var something

could be changed to

add 'var something
It's kinda like the += in C.
'var + something
hmm... that's not too readable.
Endo
12-Oct-2011
[2427]
infix functions, op!s should not support this, because it is really 
not readable
Geomol
12-Oct-2011
[2428]
Yeah, I tend to agree.
Endo
12-Oct-2011
[2429]
what about writing a bunch of new functions suffixed with '
ADD'
NEXT'
Geomol
12-Oct-2011
[2430]
Yes, REBOL makes it possible to do all this already. In fact, all 
the natives could be recreated as mezzanines supporting call-by-name, 
but that'll be slow of course.
Endo
12-Oct-2011
[2431x3]
You can easily see the extra overhead:
SOURCE ++
additional IF, GET, SET and CASEs..
this should be in all the natives. look too much overhead I think.
Let's wait for comments from gurus.
I'm leaving now. Bye.
Geomol
12-Oct-2011
[2434]
ciao
Endo
13-Oct-2011
[2435]
There is a huge speed difference: (my benchmark function executes 
given block 1'000'000 times)
>> i: 0 benchmark [i: i + 1]
== 0:00:00.25
>> i: 0 benchmark [++ i]
== 0:00:02.578
Geomol
13-Oct-2011
[2436x4]
That's more the difference between a native and a mezzanine, than 
the method.
Related is using POKE on e.g. time!:

>> t: 10:20:30
== 10:20:30
>> poke t 2 42
== 10:42:30
>> t
== 10:20:30

But we can change a time using a set-path!:

>> t/2: 42
== 42
>> t
== 10:42:30

So the set-path! way doesn't do the same as POKE in this case.
That was in R2. In R3, POKE can't handle time!
And that's probably an ok decision.
Endo
13-Oct-2011
[2440]
That's more the difference between a native and a mezzanine, than 
the method.
 - That's right.
Geomol
13-Oct-2011
[2441]
From R3, where ++ is native::

>> dt [loop 10000000 [i: i + 1]]
== 0:00:01.90374
>> dt [loop 10000000 [++ i]]
== 0:00:01.011743
BrianH
13-Oct-2011
[2442]
Try it in R3:
>> dt [i: 0 loop 1000 [i: i + 1]]
== 0:00:00.000251
>> dt [i: 0 loop 1000 [++ i]]
== 0:00:00.000383


Then the difference is more due to the code in ++ to tell whether 
i is an integer or a series
Geomol
13-Oct-2011
[2443]
Hm, try do more loops on your system, Brian.
BrianH
13-Oct-2011
[2444x3]
Weirdly enough, I think that it might be faster sometimes depending 
on what is going on in the background.
Nope, consistently faster. No interpreter overhead.
>> dt [i: 0 loop 100000 [i: i + 1]]
== 0:00:00.041421
>> dt [i: 0 loop 100000 [++ i]]
== 0:00:00.022857
>> dt [i: 0 loop 1000000 [i: i + 1]]
== 0:00:00.205488
>> dt [i: 0 loop 1000000 [++ i]]
== 0:00:00.130813
Geomol
13-Oct-2011
[2447x2]
Yes, ++ is faster, contrary to your first test.
And it makes sense.
BrianH
13-Oct-2011
[2449]
The ++ and -- functions are in R2 for convenience and compatibility, 
not for speed.
Ladislav
13-Oct-2011
[2450]
++ is native in R3
Geomol
13-Oct-2011
[2451]
yes and yes
BrianH
13-Oct-2011
[2452]
Still, I made them as fast as I could while still being compatible.
Geomol
13-Oct-2011
[2453]
So we would expect things like

	next 'series

to be faster aswell than

	series: next series
BrianH
13-Oct-2011
[2454]
But not as useful. The current NEXT can operate on values returned 
from functions, or series referred to by protected variables.
Geomol
13-Oct-2011
[2455]
My suggested NEXT can do that also. I just suggest adding the possibility 
to call those with call-by-word.
Ladislav
13-Oct-2011
[2456x3]
NEXT cannot do it
It does not have that kind of argument evaluation
You would need to change the argument evaluation standard for it
BrianH
13-Oct-2011
[2459x2]
Geomol, if you change NEXT to call-by-word then in order to have 
it work on the results of a function you will need to assign those 
results to a temporary word, then in a separate statement run the 
NEXT. No more chaining.
If you try to support both then you lose the ability of NEXT to trigger 
an error if it is passed a word by accident, a valuable debugging 
aid.
Geomol
13-Oct-2011
[2461x2]
:)
I didn't suggest changing NEXT to call-by-word. I suggest adding 
that possibility beside its current behaviour.
Ladislav
13-Oct-2011
[2463]
Do you happen to know how?
Geomol
13-Oct-2011
[2464x2]
>> f: func [v] [either word? v [get v] [v]]
>> f 1
== 1
>> a: 2
== 2
>> f 'a
== 2
That's the thought.
BrianH
13-Oct-2011
[2466]
Yeah, that will make NEXT cause unintentional side effects instead 
of triggering errors. Does it have side effects or not? Who knows?
Ladislav
13-Oct-2011
[2467]
aha, so you are suggesting to just accept word as yet another type 
of argument, i.e. to support NEXT 'A
Geomol
13-Oct-2011
[2468x2]
yes
Mezzanine example:


>> my-next: func [series] [either word? series [set series next get 
series] [next series]]
>> my-next [a b c]
== [b c]
>> block: [a b c]
== [a b c]
>> my-next 'block
== [b c]
>> block
== [b c]