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

World: r3wp

[!REBOL3-OLD1]

Steeve
15-Jan-2009
[9676x2]
do that then...
(it's not an order just a request)
[unknown: 5]
20-Jan-2009
[9678]
Any change to get a CONTINUE function in R3?
Henrik
20-Jan-2009
[9679]
>> continue
** Throw error: No loop to continue

This what you want?
[unknown: 5]
20-Jan-2009
[9680]
yeah is that in R3?
Henrik
20-Jan-2009
[9681]
yes, I have it in latest alpha here:

>> ? continue
USAGE:
        CONTINUE

DESCRIPTION:
        Throws control back to top of loop.
        CONTINUE is a native value.
[unknown: 5]
20-Jan-2009
[9682]
Excellent!  We needed that.
Henrik
20-Jan-2009
[9683]
goodie :-)
[unknown: 5]
20-Jan-2009
[9684x3]
You know what it does right?
It allows you to skip the rest of a while loop for example when the 
conditions are met.
This means far less evaluation is needed in your loops.
Sunanda
20-Jan-2009
[9687]
If you need to, you can fake it in r2 with loop 1 [...break ...]
R3 ---  for n 1 5 1 [print n continue print "not printed"]
R2 ---  for n 1 5 1 [loop 1 [print n  break print "not printed"]]
[unknown: 5]
20-Jan-2009
[9688x3]
A continue should skip the rest of a loop cycle and advance the loop 
to the next cycle based on the condition of the loop.  This means 
it is far more efficient than our current methods.
Break doesn't initiate the next cycle of the loop.
Yes Sundanda, your second method would do the trick but then your 
also introducing evaluation.  So you gotta be careful you not introducing 
more evaulation than your saving.
Sunanda
20-Jan-2009
[9691]
You may be disappointed in continue then.....At least in the current 
alpha some evaluation takes place.
     R3 ---  for n 1 5 1 [print n continue xxx: 999]
     R2 ---  for n 1 5 1 [loop 1 [print n  break xxx: 999]]
Both R2 and R3 end up with xxx as an unset word in system/words
Henrik
20-Jan-2009
[9692]
Sunanda try profiling the R3 version with and without the xxx word 
and see if there is a speed difference. If not, then the word appears 
due to binding on first use of the block.
[unknown: 5]
20-Jan-2009
[9693x2]
Not really evaulation as much as type checking possibly.  Even the 
following will add to the system/words:

>> loop 1 [break blah: 1]
>> find first system/words 'blah
== [blah]
I think system/words is similiar to a string table as found in other 
languages with respect to literals.
BrianH
20-Jan-2009
[9695x2]
CONTINUE has the same overhead as BREAK, EXIT and RETURN, so be sure 
to factor that in in your performance calculations.
It can be really convenient though :)
[unknown: 5]
20-Jan-2009
[9697]
What overhead?
BrianH
20-Jan-2009
[9698x3]
It's similar to a THROW, setjump/longjump overhead mostly.
That is why returning a value as the last expression of a function 
is faster than using the RETURN function.
REBOL isn't compiled so it's not the same thing as in a native language.
Chris
20-Jan-2009
[9701x2]
Brian, is it possible to expand on that (setjump/longjump), or is 
there a Carl post that summarises?  This is good to know - specifically 
as it relates to R2 and R3 implementation...
For example, [return true] vs [true] or ["a" exit | other rule]
BrianH
20-Jan-2009
[9703]
It's the same in R2. PARSE is diifferent though, but exit or return 
in the parens has the same overhead.
[unknown: 5]
20-Jan-2009
[9704]
I don't see how the overhead of continue would be greater than the 
overhead of further evaluation where it isn't used.
Sunanda
21-Jan-2009
[9705]
I tried timing tests on my R2 ad R3 examples.
R3 runs in about half the time. 

Conclusion: 'continue is a good optimisation over loop 1 [...break...]

That does not say anything about the overheads of 'continue.....Just 
that an extra loop is an extra overhead.
Oldes
21-Jan-2009
[9706x2]
>>  loop 1 [break blah: 1 blahblah: 2]
>> find first system/words 'blahblah
== [blahblah]
I think that Rebol first must parse the block to evaluate into 'tokens', 
that's why the words are defined as unset in the system/words
DideC
21-Jan-2009
[9708x3]
Exactly. It must load the block, so create the words. Then it can 
do it.
REBOL/View 2.7.6.3.1 14-Mar-2008
Copyright 2000-2008 REBOL Technologies.  All rights reserved.
REBOL is a trademark of REBOL Technologies. WWW.REBOL.COM
>> load [blah: 1]
== [blah: 1]
>> find first system/words 'blah
== [blah]
>> blah
** Script Error: blah has no value
** Where: halt-view
** Near: blah
REBOL/View 2.7.6.3.1 14-Mar-2008
Copyright 2000-2008 REBOL Technologies.  All rights reserved.
REBOL is a trademark of REBOL Technologies. WWW.REBOL.COM
>> loop 1 [break blah: 1]
>> find first system/words 'blah
== [blah]
>> blah
** Script Error: blah has no value
** Where: halt-view
** Near: blah
Anton
21-Jan-2009
[9711x2]
By the way, doing

	find first system/words 'any-word-you-like


will always succeed, because before the console evaluates this line, 
it first loads it, so the word will be added, and thus, be found.
A better test is:

	"any-word-you-like" = last first system/words

which does not introduce a new word before evaluation is done.
[unknown: 5]
21-Jan-2009
[9713]
>> loop 1 [break blah: 2]
>> last first system/words
== blah
Henrik
21-Jan-2009
[9714]
Anton, I think that would be a nice topic for a blog post.
btiffin
21-Jan-2009
[9715]
Very Heisenberg; Call the post, Anton's Postulate for getting round 
the REBOL uncertainty principle.   ;)
[unknown: 5]
21-Jan-2009
[9716]
How do I submit a request for Carl to include a feature in R3?
Henrik
21-Jan-2009
[9717x2]
rebdev is the shortest path for now. I can relay it.
except, rebdev seems to be down. he said that some changes were going 
to be made... will see if it comes back up in a few hours.
[unknown: 5]
21-Jan-2009
[9719x2]
Henrik my request is a change for ports.
You know the way we have open/lines function,  I would like to see 
open/blocks function.
Henrik
21-Jan-2009
[9721]
have you worked with R3 ports yet? they are very different from R2 
ports.
[unknown: 5]
21-Jan-2009
[9722x2]
No, I don't have access to it.
I just figure I hadn't seen it mentioned of having this feaure.
Henrik
21-Jan-2009
[9724]
rebdev was up. the client was too old. :-)
[unknown: 5]
21-Jan-2009
[9725]
Good are you making the request?