World: r3wp
[Core] Discuss core issues
older newer | first last |
Andreas 31-Oct-2010 [270x2] | in 2.7.7 at least |
Part of R2/Forward. | |
GrahamC 31-Oct-2010 [272] | Ah... I'm using 2.7.6 and they're not there |
Andreas 31-Oct-2010 [273] | Then just write the single line that is flatten :) |
GrahamC 31-Oct-2010 [274x3] | done that ... |
I thought there might be some other trick I could use | |
well, I will use the to-block form and if that errors out drop back to flatten | |
PeterWood 31-Oct-2010 [277x2] | Try parse, it should be quick: >> parse [["xxx"] ["yyy"] ["zzz"]] [(f: copy []) any [set b block! (append f first b)]] == true >> f == ["xxx" "yyy" "zzz"] |
Of course, it would be quicker using insert back tail but that would have made the one-liner longer ;-) | |
Andreas 31-Oct-2010 [279] | Nevermind, it's already verbose enough :) |
GrahamC 31-Oct-2010 [280] | parse it is then! |
Andreas 31-Oct-2010 [281] | Speed, speed, speed! :) |
GrahamC 31-Oct-2010 [282] | well, I thought we should really have a native for this .... where's Cyphre's JIT compiler?? |
Gregg 1-Nov-2010 [283] | Why should it be native? |
Maxim 1-Nov-2010 [284] | cause its going to be A LOT faster and for things like database queries, this can become quite a bottleneck. |
Gregg 1-Nov-2010 [285] | Give me some numbers. Show me scenarios where it's a bottleneck. I should have a second log in here. P.O., because I'm sure I Piss Off a lot of people by always questioning Premature Optimization. :-) |
Ladislav 1-Nov-2010 [286x3] | LOL |
How about a LINE-NUMBER? function yielding a line-number of a string, would you want such a function to be a mezzanine? | |
(the function is available at http://github.com/rebolsource/rebol-test , BTW) | |
Gregg 1-Nov-2010 [289] | I want pretty much *everythihng* to be a mezzanine until we know the gains are worthwhile and will benefit enough people. That still gives us room to be subjective. ;-) |
Ladislav 1-Nov-2010 [290] | I am the author, so if somebody different from myself wants to have the function as a mezzanine, fill in a CC ticket |
Maxim 1-Nov-2010 [291] | gregg. such simple functions cannot be optimized in rebol simply because the lowest-level loops are VERY slow. this is a simple function which requires no special treatment. for such a function, the moment its written as a mezz, we can't say "premature" optimisation... its done. the only improvement is to make it 20 times faster. |
Gregg 1-Nov-2010 [292x2] | You're missing my point Max. I'm saying it doesn't need to be optimal yet, because we have no idea if it's worth optimizing. |
Heck, we don't even have it as a standard function. :-) | |
Andreas 1-Nov-2010 [294] | You are also missing another point. Graham's original statement was meant to be ironic :) |
Gregg 1-Nov-2010 [295] | I missed the irony. My apologies. |
Ladislav 2-Nov-2010 [296] | Another potentially useful function: CATCH-ANY. Can be found at: http://github.com/rebolsource/rebol-test as well. |
BrianH 2-Nov-2010 [297] | Post it to the idioms group in R3 chat #754, either the file, a link to the original, or as source in a message. |
Ladislav 3-Nov-2010 [298x3] | The CATCH-ANY function above catches almost all REBOL exceptions. One that it does not catch is HALT. Is HALT meant to be "uncatchable", or not? |
(shall this question be CureCoded?) | |
My preferences are, that HALT should be catchable, since that would allow us to e.g. write a REBOL console in View. | |
Maxim 3-Nov-2010 [301] | catch halt could be a nice wish |
Ladislav 3-Nov-2010 [302x2] | Done |
Examining the core-tests suite results I wonder, which alternative do you prefer: a: >> for i 1 3 1 [print i if i = 1 [i: 2]] 1 2 3 == none b: >> for i 1 3 1 [print i if i = 1 [i: 2]] 1 3 == none | |
GrahamC 3-Nov-2010 [304x6] | latter |
it's like a loop | |
sort of | |
actually that's a construct I miss.... eg. in dbase we had do loop [ ............ ] endloop or something like that. but you could exit anyway inside that block to restart the loop like this do loop [ .... loop .... ] endloop | |
we only have break which exists a loop | |
exits | |
Sunanda 3-Nov-2010 [310x2] | You can do it with an idiomatic use of LOOP 1 [...] But that loses an easy way to use BREAK for real. for n 1 5 1 [ loop 1 [ if n < 3 [break] print n ] ] |
R3 has CONTINUE for n 1 5 1 [ if n < 3 [continue] print n ] | |
GrahamC 3-Nov-2010 [312] | need a break^2 |
Ladislav 3-Nov-2010 [313] | you mean for this?: for n 1 5 1 [ catch/name [ if n < 3 [throw/name none 'continue] print n ] 'continue ] |
GrahamC 3-Nov-2010 [314] | yes .. but in one word :) |
Ladislav 3-Nov-2010 [315x3] | cc: func [[throw] body [block!]] [catch/name body 'continue] continue: func [[throw]] [throw/name none 'continue] |
for n 1 5 1 [ cc [ if n < 3 [continue] print n ] ] | |
Can be made even more elegant, since FOR is a mezzanine | |
GrahamC 3-Nov-2010 [318] | that would be good |
Anton 3-Nov-2010 [319] | CC being a function, would that mean RETURN or BREAK could not be used? eg. myfunc: func [][ for n 1 5 1 [ cc [ if mycondition [return] ] ] ] (until converted to native?) |
older newer | first last |