World: r3wp
[Core] Discuss core issues
older newer | first last |
Steeve 19-May-2009 [13810] | speed is a priority especially with Rebol which can be really slow if you don't take care |
Janko 19-May-2009 [13811x4] | functional: reduce [ "hi " (either is-male? gender [ "boy" ] [ "girl" ]) , "how are you?" ] vs imperativeish: a: "hi " either is-male? gender [ append a "boy" ] [ append a "girl" ] append a " How are you?" a |
so although I got impression from Carl's blogposts that he thinks rebol should be practical vs. functional , I think a lot of it's power and elegance and practicality come from functional aspects of it (just expressing my opinion) | |
( ok, my memory was bad, Carl only said rebol is not Pure Functional PL , which is totally different thing and I don't want it to be pure functional :) ) | |
http://www.rebol.com/article/0206.html | |
Steeve 19-May-2009 [13815x2] | i think the power of rebol comes from the big amount of small code schemes so that by combining only some of them you can do all you want. It's the main difference with other functional languages. The amount of natives schemes and data types. |
Adding more and more natives schemes (like matrix operations on series) is the way to get Rebol more and more powerful | |
Maxim 19-May-2009 [13817x3] | the unification of series management is one of the major sources of code reduction in rebol. |
the other is the fact that series are mutable, and many functions edit the input series directly. | |
even more so in R3 :-) | |
Graham 19-May-2009 [13820] | This works ... posting a message is actually called updating your status! page: read/custom [ scheme: 'http host: "twitter.com" target: "statuses/update.xml" user: "my-twitter-id" pass: "mypassword" ] [ POST "status=Playing with REBOL and the Twitter API" ] |
Steeve 19-May-2009 [13821x2] | interesting, can you post other messages than "status=" ? |
(never used twitter) | |
Graham 19-May-2009 [13823] | http://apiwiki.twitter.com/Twitter-API-Documentation |
Henrik 22-May-2009 [13824] | is there a quick way to tell if an integer overflows? I'm missing an overflow? function: overflow? 632479375863785946758934675892 == true |
BrianH 22-May-2009 [13825] | int-overflow?: func [n [number!]] [error? try [to-integer n]] |
Henrik 22-May-2009 [13826] | hmm.. yes, thanks. |
Maxim 22-May-2009 [13827] | unfortunately this might not work... to-integer sometimes returns a decimal... unlesss its been fixed for 2.7.6 |
BrianH 22-May-2009 [13828] | It should work - always return integer! or error! - if the input is a number! (as specified in the type test of the argument. TO-INTEGER would only have that problem with string input. |
Maxim 22-May-2009 [13829] | aaah yes... missed the input type ... sorry. |
Graham 26-May-2009 [13830x2] | any good reason apart from the fact that data is a block that this is not allowed? forskip data: [ 1 2 3 4 ] 2 [ ] |
but you have to do: data: [ 1 2 3 4 ] forskip data 2 [ ... ] | |
Maxim 26-May-2009 [13832x2] | cause the word is being used as the index. |
probably cause in the time frame of evaluation the set word happens after the forskip hits it. | |
Graham 26-May-2009 [13834] | Is that a good reason? :) |
Maxim 26-May-2009 [13835] | the assignment I mean. |
Izkata 27-May-2009 [13836] | USAGE: FORSKIP 'word skip-num body Yep, the set-word gets assign to word, the [1 2 3 4] gets assigned to skip-num, and 2 gets assigned to body, because of the lit-word argument in forskip |
Graham 27-May-2009 [13837x2] | Maybe this should be changed so that a default word is used instead ... |
if a lit-word is not supplied as an argument but a block | |
Izkata 27-May-2009 [13839] | Perhaps split the iteration word argument from the data argument, like 'foreach has? |
Graham 27-May-2009 [13840] | seems a reasonable suggestion. |
BrianH 27-May-2009 [13841x2] | FORALL and FORSKIP are faster than FOREACH in R3 because they don't have a local word that requires a BIND/copy of the code. |
You don't notice this in R2 because they're mezzanine and all of that overhead is greater, but it is noticable in R3 where they are native. | |
Dockimbel 27-May-2009 [13843] | Wouldn't it be more efficient to just BIND instead of BIND/copy body blocks in loops by default, and additionnally provide a /copy refinement in the (very) rare cases where you don't want the body block to be modified? Is it a design decision or did I missed some obvious reason? |
BrianH 27-May-2009 [13844] | You have to BIND/copy or *EACH would not be recursion-safe (or task-safe in R3). |
Dockimbel 27-May-2009 [13845] | I thought about the upcoming task! support but forgot about the "recursion" case. I might have wrote only 3 or 4 functions in 10 years of coding in REBOL that fall in that case (that's why in R2, it could have been no-copy by default). But tasking in R3 should make it more frequent I guess. |
BrianH 27-May-2009 [13846] | I guess I write more recursive code than you do :) |
Dockimbel 27-May-2009 [13847] | That's very possible, I use recursion only when the gain in code size or clarity looks obvious. Also, not having tail-call optimization doesn't push you much toward recursive approach in the general case. |
BrianH 27-May-2009 [13848] | I use it for building or processing recursive data structures - it's faster for that, tail-call-optimized or not. I only switch to iteration and hacks if the data blows the stack, which is rare. |
Dockimbel 27-May-2009 [13849] | The recursive calls limit used to be quite low (150-200 calls), has that limit been extended in recent 2.7.x versions? |
BrianH 27-May-2009 [13850] | I think so, but don't know. Haven't run into it so far, since I don't do recursive loops, just trees. |
Steeve 27-May-2009 [13851] | So you don't use recursive calls inside FOREACH loops... |
BrianH 27-May-2009 [13852] | Too restrictive. |
Dockimbel 27-May-2009 [13853] | I agree, using recursion for walking through hierarchical structures is a good approach as these structures usually have a depth limit far below the stack limit (e.g. parsing XML data) . In the last years, I've found that using block parsing for block! trees walking was probably the most efficient approach (code size and speed wise). |
Steeve 27-May-2009 [13854x2] | yep i use parse too, to do so. It doesn't need rerursives functions |
faster, One call with parse | |
BrianH 27-May-2009 [13856] | I prefer to use PARSE when I can, but recursion can be tricky if you use local variables. Not (always) impossible, but tricky. It's on the list to be fixed with the R3 parse proposals. |
Steeve 27-May-2009 [13857] | I know, i saw many implementations wich use recursive calls of parse (to deal with local var) in the past. But i don't like that. I saw it's slower most of the time than using recursive rules (well, it's the purpose of parse) |
BrianH 27-May-2009 [13858] | It's not always possible to refactor the parse rules to make the variable usage recursion-safe. Most of the time it is though. |
Steeve 27-May-2009 [13859] | even in that case, i prefer to code an emulated stack (using a block) |
older newer | first last |