World: r3wp
[!REBOL3-OLD1]
older newer | first last |
Sunanda 16-Apr-2008 [5824x2] | This may be what you want: series: ["a" "b" "c" ] somefunc: func [x] [print pick series x] >>somefunc 1 == a |
This works in recent versions of REBOL: somefunc: func [x] [print pick series/:x] note the ":" before the "x" | |
Pekr 16-Apr-2008 [5826] | series/:x or series/(x) |
Sunanda 16-Apr-2008 [5827] | oops -- remove the 'pic from that second example: somefunc: func [x] [print series/:x] |
LuisE 16-Apr-2008 [5828] | thank you that worked the .x didn't but the (x) did |
BrianH 16-Apr-2008 [5829] | It wasn't a .x, it was a :x in his example - try that. |
LuisE 16-Apr-2008 [5830x2] | that works too |
thanks | |
BrianH 17-Apr-2008 [5832x2] | This was in response to a question from Jerry: And what is "the new behavior of function!" that you mentioned? Cross-posted by request. |
Jerry, R2 just had one kind of context (2 if you include the autoexpand context used by system/words). Functions, objects and USE all used this type of context, and words were bound to this kind of context. A function! in R2 is bound to one of these contexts, which gets reused when the function is called. When the function is called recursively, the value block of the context is pushed on a stack but the context is reused - this is the main reason R2 could never be thread-safe. The only difference that object! contexts have over function! or USE contexts is that the word 'self is added to them. In R3, there is at least one more context type: stack-relative, which is used by the function! type. All of the words bound to a function! resolve their bindings relative to the context in the executing stack frame, rather than directly. When a function! starts it allocates a context on the stack; when it ends it deallocates the context. This means that the context of words bound to a function only exists when the function is running, so there is no point to referring to these words outside of the function. Although this slows down word references, it speeds up function! calls and reduces potential memory leaks due to word references in functions after they have returned. This slowdown in word references is the reason that R2-style rebcode doesn't make sense to add to R3 without some changes to its semantic model to make up for the difference. A closure! in R3 is like a USE call in R2 (USE in R3 is implemented using closure!). The words are direct-bound to a context (so word references are faster), but it creates a new context and bind/copy's the code block at the beginning of each closure! call. There is still no point to bind a word to a closure's context when the closure isn't running, since the next time the closure runs it will create a new context, but it does make sense to use a context created by a closure call after the closure has returned since it is a regular context like a R2 USE context. In general, it is better to use function! unless you need to refer to the context after the closure! returns - mostly useful for generators, currying and other functional programming tricks. In R3, object! contexts are like the R2 system/words context: they can expand, but not shrink; closure! and function! contexts can't expand though. There will be further changes to the way object! contexts work, and module! contexts will behave the same way. | |
btiffin 17-Apr-2008 [5834] | http://rebol.net/wiki/Brian%27s_Take_on_Context Docbase Link of above. It's beefee. Thanks Brian. |
BrianH 19-Apr-2008 [5835x2] | I expanded the above article, making it easier to understand and with more information. http://rebol.net/wiki/R2_vs._R3_Contexts |
By the way, it turns out that function! word references are around 28% slower than closure! or object! word references. | |
Rod 19-Apr-2008 [5837x2] | BrianH, thanks for that context information, very good to keep in mind in both R2 and R3. |
I'm struggling a bit with the closure! specifics. I have used closures in Ruby (though I'm not clear on the difference between a block using yield and a closure at this point) and part of what I thought made valuable was the connection to the context they were formed with that persists. I'm probably getting this all wrong but what does "next time tthe closure runs it will create a new context" imply on that front? | |
BrianH 19-Apr-2008 [5839x2] | If Ruby is as much like Smalltalk as I remember, a block is like an anonymous function, and functions in Ruby are more like closures in REBOL. There is nothing like yield in REBOL yet, though I don't know whether Ruby's yield is a cooperative multitasking thing or an Icon-style resumable return for generators. |
Ruby has the general overhead of indirect word binding so it can support things like closures directly, which is why it is slower than REBOL overall. On the other hand, REBOL has a lot of overhead when creaing closures because of its direct binding, but that same direct binding is part of what makes REBOL so fast otherwise. It's a tradeoff. | |
Kaj 21-Apr-2008 [5841x2] | That sounds about right |
I think Ruby's yield is both for cooperative multi-tasking and generators | |
BrianH 21-Apr-2008 [5843] | Some languages use multitasking for generators - Icon doesn't. Does Ruby have Icon-style resumable return? |
Kaj 22-Apr-2008 [5844] | I daren't say. I don't know Icon |
Rod 23-Apr-2008 [5845] | I don't know Icon either and I'm not sure about the cooperative multi-tasking part for Ruby, only seen the generators use so far. |
Henrik 1-May-2008 [5846x2] | A tiny bit of status report: - Working on ports now. It's a very straight forward system, if you've been reading the docs. - Carl found a bug in the garbage collector that would speed up a loop test case from 35.2 seconds to 6.4 seconds. - After a while of core unicode testing, graphics is finally going back in. The third test version of View with unicode is going to be released soon. - Still no unicode support inside View graphics, though. - 445 bug reports so far. - HTTP protocol recently done (IMHO a very nice and super-clean implementation of http1.1 by Gabriele). - Test case system temporarily put on hold. Ports are more interesting. :-) - WAIT now switches between efficiency and accuracy. It's accurate but CPU intensive when selecting a WAIT lower than 1 ms, because in those cases it uses it's own routine for waiting, but it can be done much more accurately than the OS timer. When above 1 second, it uses the OS timer. |
oops, in the last line it should read "WAIT lower than 1 second", not 1 ms. :-) | |
[unknown: 5] 1-May-2008 [5848] | Henrik, sounds interesting. Thanks for the status report. |
Gabriele 1-May-2008 [5849] | note, afaik the wait < 1 s problem only applies to windows. (although, other oses may have long context switches too) |
Henrik 2-May-2008 [5850x2] | >> ? evoke USAGE: EVOKE chant DESCRIPTION: Special guru meditations. (Not for beginners.) EVOKE is a native value. ARGUMENTS: chant -- Single or block of words ('? to list) (word! block!) :-) |
not really sure what it does, but it's used for debugging | |
Gabriele 2-May-2008 [5852x2] | sets secret internal options. |
:-) | |
Henrik 3-May-2008 [5854] | REBOL 3 Alpha 2.100.10 Unicode Init System Port REBOL Host-Init Built: 1-May-2008/21:33:53-7:00 Language: dansk - Denmark 56 datatypes, 68 actions, 141 natives 1021 words defined >> stats == 583680 |
sqlab 3-May-2008 [5855] | How about wait 0? I used it a few time just to be sure that an event got really triggered. |
Pekr 6-May-2008 [5856x4] | So, as we just decided to make Curl guys to close the Nitro doors, because R3 will be much cooler, the last phase of two months plan started just 5 minutes ago - http://www.rebol.com/rebol3/next.html .... yes, we are back to VID 3, with prior phases more or less finished .... just to let you know .... |
Ah, I forgot to provide a smiley to the Curl remark :-) | |
.... or not? ;-) | |
Simple, Clean VID Requirements - http://www.rebol.net/r3blogs/0132.html | |
btiffin 6-May-2008 [5860] | I added my 2 cents. |
AdrianS 8-May-2008 [5861] | It would be really nice if Rebol 3 included some grid computing functionality out of the box. Something as simple to set up and get going as GridGain - http://www.gridgain.com.Or is it already very easy to achieve a master-worker kind of solution? |
Graham 8-May-2008 [5862] | What about just support for EC2 etc? |
PeterWood 8-May-2008 [5863x4] | What about just support for Gmail? |
Henrik: Do the 56 datatypes include audio! and video! yet? | |
I know Pekr has talked about Rebol needing better multimedia support in the past ...I think he's right. | |
I'm also thinking about starting a save our hash! campaign - it's great for building unique lists. | |
Oldes 8-May-2008 [5867] | map! will be used for fast unique lists. And it's too soon for multimedia datatypes... I think audio/video will not be datatype at all, rather a scheme I guess. |
BrianH 8-May-2008 [5868] | Don't forget user-defined datatypes, which will also be in R3. Some of the missing types will be added that way. |
PeterWood 12-May-2008 [5869] | Will we be able to use find against a map! ? |
BrianH 12-May-2008 [5870] | I think so, but you probably won't need to - map! is optimized for this kind of task without needing find. |
Pekr 24-May-2008 [5871] | There starts to be series of VID3 blogs. So - those who want to affect some design principles, can share their opinion there .... |
Graham 24-May-2008 [5872x2] | Is there any way we can have a hybrid R2 with the new graphics system and the old core? |
Some of us are tied to R2 because of networking | |
older newer | first last |