World: r3wp
[Core] Discuss core issues
older newer | first last |
Izkata 31-Mar-2009 [13413] | Then again, R2 has surprised me with my current project |
Graham 31-Mar-2009 [13414] | networking is not a strong point |
Anton 31-Mar-2009 [13415x2] | Geomol, your last "potential problem with ALSO" is not exclusive to ALSO. It's a potential problem anywhere COPY is abused by a programmer not knowing what's going on. The way to return the large amount of data and to release the local from it is of course like this: also local-data local-data: none |
load-mp3-data: func [file /local contents][ contents: read/binary file ; <- modify contents here also contents contents: none ] data: load-mp3-data %song.mp3 | |
Graham 31-Mar-2009 [13417] | so this frees contents?? |
Steeve 31-Mar-2009 [13418] | just to say there is no need anymore to unset the local vars in R3 |
Anton 31-Mar-2009 [13419x4] | In the load-mp3-data function above, a large binary series is loaded and contents set to refer to it. The ALSO line returns the binary series and unsets CONTENTS so that it no longer refers to the binary series. The usage code below the function definition takes the return value (the binary series) and sets DATA to it. So effectively the variable referencing the binary series has been switched with another one. |
(Steeve, yep.) | |
Graham, no, it just "unhooks" the local word CONTENTS from the binary series data. | |
Which is a good thing to do, because now the function does not maintain a reference to the large binary series after it has been called. | |
Steeve 31-Mar-2009 [13423] | If the contents var is not unset and then the load-mp3 function is not anymre called. Then, the garbage collector can't free the serie because it stays handled by the local var contents. |
Graham 31-Mar-2009 [13424x2] | Hmm. So, one should deference local vars if they pointing to large data sets? |
dereference | |
Steeve 31-Mar-2009 [13426] | yes, In R2 we should |
Anton 31-Mar-2009 [13427] | Steeve, yes, that's right. |
Graham 31-Mar-2009 [13428] | didn't know that ... |
Anton 31-Mar-2009 [13429] | Yes, in R2, functions don't bother to unset their local words on function exit. This was done for speed reasons. Most functions don't need to unset their locals. |
Graham 31-Mar-2009 [13430] | I wonder if that would help with the problem I had before when I was doing OCR on image data .. and kept getting crashes |
Anton 31-Mar-2009 [13431] | Where you running out of memory? |
Graham 31-Mar-2009 [13432] | no |
Anton 31-Mar-2009 [13433] | *Were you.. |
Graham 31-Mar-2009 [13434] | If I turned off recycle, the problem disappeared, but then memory eventually would run out |
Anton 31-Mar-2009 [13435] | That was more likely some external library call problem. |
Graham 31-Mar-2009 [13436x3] | not using external libraries |
I was posting the data to a web server | |
web service | |
Anton 31-Mar-2009 [13439] | That was a memory leak, not really caused by the "local vars not unset on R2 function exit" behaviour. (But perhaps contributed, by misunderstanding, to the leak bug.) |
[unknown: 5] 31-Mar-2009 [13440] | Yes, Graham we need to clear those locals by setting them to none. |
BrianH 31-Mar-2009 [13441] | I use ASLO in R2-Forward for that reason - that was the original reason ALSO was suggested. You don't need ALSO for that in R3 since the locals unset themselves in the new function context model, but it is useful for closing ports and changing directories back. |
[unknown: 5] 31-Mar-2009 [13442] | Brian, are the parameters in R3 also unset in R3? |
BrianH 31-Mar-2009 [13443x3] | R3 has stack frames, so the entire frame - including the locals - is tossed after the function returns. |
Closures are different though - a whole new context is created with each call, words and values both. | |
Closures are for doing "memory leaks" on purpose :) | |
[unknown: 5] 31-Mar-2009 [13446] | Will we get any control over the stack? So that we can potentially perform recursive operations without overflow? |
BrianH 31-Mar-2009 [13447x2] | Unlikely, since most tail recursion optimizations require an optimizer, or at least a compiler. Manual access to the stack is a security hole (unless the language is Cat). Accept that REBOL has real loops and that imperative programming is more efficient in an interpreted language :) |
REBOL was designed to be interpreted efficiently. Don't compare it to languages that were designed to be compiled (like Haskell) or languages that aren't designed for efficiency (like Scheme). | |
[unknown: 5] 31-Mar-2009 [13449] | Yeah I understand that. |
BrianH 31-Mar-2009 [13450x2] | REBOL 1 had tail-recursion optimizarion. REBOL 2 got rid of it on purpose, and got 30 times faster as a result :) |
There were some other tricks that contributed, like getting rid of continuations and ELSE. | |
[unknown: 5] 31-Mar-2009 [13452] | Carl sharing this much with you or how do you know this about REBOL? |
BrianH 31-Mar-2009 [13453] | I was one of the beta testers of REBOL 2 - I've been around that long :) |
[unknown: 5] 31-Mar-2009 [13454x2] | I can't remember what version I started with REBOL in. I just know the year was 98. |
But I walked a way a bit at times as the lack of development waned. | |
BrianH 31-Mar-2009 [13456] | Earlier than me - I started in 99, with REBOL 1.0.3. |
[unknown: 5] 31-Mar-2009 [13457] | I remember back then we had Holger, Jeff, and Sterling. |
BrianH 31-Mar-2009 [13458] | I miss those guys. The beta list for R2 started a month after I arrived. |
[unknown: 5] 31-Mar-2009 [13459] | Yeah I found out about REBOL through a listserv I was on at the time with a bunch of Cisco Engineers. |
BrianH 31-Mar-2009 [13460x2] | I think I saw it mentioned on Usenet. We had Joel Neely too - he wrote the R1 interpreter, which was so slow (because it was like Scheme) that Carl had to rewrite it from scratch: REBOL 2. That is why Neely flames REBOL on the Scheme lists. |
(I may have the name wrong though - I'm really bad at names.) | |
[unknown: 5] 31-Mar-2009 [13462] | Wow, I remember that name but didn't know about the flames. |
older newer | first last |