World: r3wp
[Core] Discuss core issues
older newer | first last |
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) |
BrianH 27-May-2009 [13860] | That can be slower than recursive calls to parse, depending, but at least you won't blow *that* stack. |
Steeve 27-May-2009 [13861] | There is another one advantage of using your own stack, you can break the process where you want and continue it later. Used to do incremental parsing (even with recursives rules). |
Dockimbel 27-May-2009 [13862] | I also use block! stacks to avoid local words issues in recursive parse rules. It would be interesting to benchmark the two approaches : (recursive functions) vs (recursive parse rules+custom stack). |
BrianH 27-May-2009 [13863x2] | Here's an example: Come up with a recursive-parse-rule version of the ARRAY function, including the function value calls. Compare. |
Wait, bad example. ARRAY is generative, so it is likely a bad candidate for PARSE. | |
Maxim 27-May-2009 [13865x2] | afaik the rebol stack goes a few thousand funcs before failing... but that depends on the amount of params you have on the functions, more args = more stack use. |
rebol stack limit: >> i: 0 a: func [][i: i + 1 a] a ** Internal Error: Stack overflow ** Where: a ** Near: i: i + 1 a >> i == 14265 | |
Dockimbel 27-May-2009 [13867] | REBOL/Core 2.5.0.3.1 >> i: 0 a: func [][i: i + 1 a] a ** Internal Error: Stack overflow ** Near: a >> i == 3151 |
Izkata 27-May-2009 [13868x2] | Rebol/View 2.7.6, 64-bit Ubuntu Hardy >> i: 0 a: func [][i: i + 1 a] a ** Internal Error: Stack overflow ** Where: a ** Near: i: i + 1 a >> i == 1705 |
1704 on /Core 2.7.6 on the same system | |
Maxim 27-May-2009 [13870x2] | wow this is pretty weird. |
I tested with rebview on windowsXP | |
Dockimbel 27-May-2009 [13872] | REBOL/Core 2.7.6.4.2 on 32-bit Ubuntu 7.10 >> i == 1705 |
Henrik 27-May-2009 [13873] | REBOL/Core 2.7.5.2.4 on MacOSX Leopard: >> i == 1334 |
Dockimbel 27-May-2009 [13874] | So WindowsXP is more recursion-friendly than Leopard...finally a good argument to not switch to MacOSX! ;-) |
Geomol 27-May-2009 [13875] | REBOL/Core 2.5.8.3.1 >> i == 3150 REBOL/View 2.7.6.3.1 >> i == 14265 Both on WinXP. |
Maxim 27-May-2009 [13876x2] | 1334 parameterless functions... that's not nearly enough for many algorythms! :-( this really has to be addressed in R3. |
its strange that view on XP has TEN times the amount of lowest target. | |
Steeve 27-May-2009 [13878] | because of the compiler option /Strange in GCC i guess |
Maxim 27-May-2009 [13879] | but why did that get set differently on winxp... maybe its something that carl never really officially set as part of the distribution specifics. |
Oldes 27-May-2009 [13880] | Because Carl is not using GCC for Win builds? |
Izkata 27-May-2009 [13881x2] | Here's something stranger |
>> i: 0 a: func [z][i: i + 1 a 1] a 1 == 1704 >> i: 0 a: func [z y][i: i + 1 a 1 2] a 1 2 == 1706 >> i: 0 a: func [z y x][i: i + 1 a 1 2 3] a 1 2 3 == 1705 | |
Steeve 27-May-2009 [13883x2] | One stack for calls, one other for parameters perhaps |
all is possible | |
Maxim 27-May-2009 [13885] | possibly the stack includes a single payload block for calls... this would make sense, in preventing stack depth variance. |
Steeve 27-May-2009 [13886] | meaning parameters are not stored in the call stack :) |
BrianH 27-May-2009 [13887x2] | Carl would not be using GCC for Win builds, because REBOL is older than the short time period that GCC has been good on Windows |
It would also depend on platform-specific stack handling. | |
Maxim 27-May-2009 [13889x4] | possibly, yes, by indirection. push stack [func args-block] and args-block is a mem copy of the args block with local values |
this is all speculation though... hehehe | |
what I am surprised overall is that rebol does not simply increase stack space. isn't that possible in current OSes? | |
I mean, the interpreter, dynamically. | |
BrianH 27-May-2009 [13893] | Function argument stacks are handled in function-specific value frame stacks in R2. They are stored in stack frames in R3, which changed the stack allocation to be more task-safe and have faster function calls. |
Steeve 27-May-2009 [13894] | Brian, i would be very suprised. Rebol uses his own way to handle stacks, if not it would be unportable. |
Maxim 27-May-2009 [13895] | I think that last post from brian wasn't speculation... I think he actualy knows, being in the R3 internal loop ;-) |
Steeve 27-May-2009 [13896] | i mean it's not platform specific. |
BrianH 27-May-2009 [13897x2] | This is one aspect of the internals that I actually am aware of, since it affects contexts. It's true: REBOL implements its own stacks, and doesn't use the C stack to call REBOL functions, just natives. |
The platform-specific aspect could be affected by page and/or pointer alignment. | |
Steeve 27-May-2009 [13899] | well, it an easy deduction, if not Rebol could not be portable |
BrianH 27-May-2009 [13900] | REBOL is not fully portable. The platform-specific parts are wrapped in APIs internally. |
Steeve 27-May-2009 [13901x2] | yes but the VM need to be fully portable |
the core engine must be | |
BrianH 27-May-2009 [13903] | This is why the R3 host code is separate, and will be open-sourced. The host code is non-portable. The VM can call API functions provided by the host code. This would be necessary for a variety of reasons, not the least of which is that memory management, tasking, networking, any number of things are implemented by different platforms differently. |
older newer | first last |