World: r3wp
[!REBOL3-OLD1]
older newer | first last |
BrianH 12-Feb-2009 [11127] | LOAD was rewritten too, as a mezzanine, by me. There is still some missing functionality, and some fixes to bugs in R2's LOAD. |
Janko 12-Feb-2009 [11128] | I am trying the do/next .. I can execute first expression but then I am a little lost of what to *do next* ( hehe)... >> b: copy [ empty? "" empty? "a" ] do/next b == [true [empty " "]] << I tried >> b: next do/next b << |
BrianH 12-Feb-2009 [11129x2] | set/any [value code] do/next code |
'value gets set to the result of the first evaluation, 'code gets set to the code block at the position after the first expression. | |
Janko 12-Feb-2009 [11131x2] | aha, that's why it says it returns two things in help |
so code is a code block and value is something that has a result that code block would return if I do it at the end ? | |
BrianH 12-Feb-2009 [11133] | >> do/next [1 + 1 2 + 2] == [2 [2 + 2]] That last block is an offset reference to the original code block. |
Janko 12-Feb-2009 [11134] | it works here too.. one strange thing is that at the last do/next I get right value for the end of the block and if I do/next again that value get's unset (I didn't know that is even possible) >>>value ** Script Error: value has no value ** Near: value<<< |
BrianH 12-Feb-2009 [11135] | >> mold/all do/next [1 + 1 2 + 2] == "[2 #[block![1 + 1 2 + 2]4]]" |
Janko 12-Feb-2009 [11136] | so now I just need to figure out how to detect when the last block is evaluated .. that is probably when the oftest block is empty... |
BrianH 12-Feb-2009 [11137] | Yup. |
Janko 12-Feb-2009 [11138x3] | I mean the whole block .. (in a loop) |
I will try | |
ha, works on all test blocks I tried :) step-block: func [ code ] [ until [ set/any [ value code ] do/next code empty? code ] value ] | |
BrianH 12-Feb-2009 [11141] | :) |
Janko 12-Feb-2009 [11142] | I thought I will ask a very very stupid question and it turns out this is very nicely possible already |
BrianH 12-Feb-2009 [11143] | Except in R3, for now :( |
Janko 12-Feb-2009 [11144x2] | would this enable us to do some sort of "green threading" without the need to maually yield even? |
absolutely no problem , if it's "for now" | |
BrianH 12-Feb-2009 [11146] | Yes, but watch out: If there is a function call, the *whole* call gets executed, even if it is long. Your granularity of preemption of your manual multithreading is going to be pretty coarse. |
Janko 12-Feb-2009 [11147x2] | yes, I know.. no long running tasks as with coroutines for example ( I am not really specialist in this, I only used it few times) |
basically I don't have the full picture, it's just awesome that something like this can be done inside a language itself | |
BrianH 12-Feb-2009 [11149] | It will be like cooperative multi-threading with no yield statement (that I can see), but an implied yield between top-level expressions. |
Janko 12-Feb-2009 [11150x2] | yes, it looks like that .. I will try to make a simple step-blocks function and see what it does |
if you would want to switch you could also step until you hit a certain word probably and then switch to other funct | |
BrianH 12-Feb-2009 [11152] | With DO/next and pseudothreads you could do full fake cooperative multithreading. |
Janko 12-Feb-2009 [11153x2] | what are pseudothreads? |
you mean the R3 threads/processes? | |
BrianH 12-Feb-2009 [11155x3] | Sorry, meant Protothreads: fake threading done with macros and special tricks. A C version: http://www.sics.se/~adam/pt/ |
The principle could be done in REBOL by preprocessing the code - easier than in C, though we don't have the switch trick. | |
C-style protothreads requires compilation to rebcode though, so we can use the brab opcode. | |
Janko 12-Feb-2009 [11158] | (the page doesn't load to me so I will keep trying) |
BrianH 12-Feb-2009 [11159] | Sorry, broken link. Try this: http://en.wikipedia.org/wiki/Protothreads |
Janko 12-Feb-2009 [11160x2] | these things are very interesting to me but I am a little |
uh.. I wanted to delete that but clicked the send button :) .. | |
BrianH 12-Feb-2009 [11162] | Aren't we all "a little", sometimes :) |
Janko 12-Feb-2009 [11163x2] | :) |
is this how stackless works (because it mentions no stack) | |
BrianH 12-Feb-2009 [11165] | If by "how stackless works" you mean Stackless Python, then no. That works using continuation passing style. |
Janko 12-Feb-2009 [11166x3] | aha, I meant stackless pythong.. you seem to really understand this stuff :) |
python = pythong | |
my "I am a little" was meant to be "unknowledgable on lower level things" | |
BrianH 12-Feb-2009 [11169] | Protothreads often work be redoing the calling stack using special tricks, or with no recursion. They're good for embedded work. |
Janko 12-Feb-2009 [11170] | interesting |
BrianH 12-Feb-2009 [11171] | They were used to implement Contiki, a multitasking embedded OS that runs on computers of Commodore 64-level capabilities. |
Janko 12-Feb-2009 [11172] | I saw it mentioned on wikipedia page.. looks interesting, but it's website doens't work either |
BrianH 12-Feb-2009 [11173] | Contiki is used by smart sensor arrays and such. Pretty hard-core stuff. |
Janko 12-Feb-2009 [11174x2] | I used to be an electronic studied automation so these things are very interesting to me... I see on google cache that last news from contiki site are " Tuesday, 03 February 2009 " so it seems page isn't abanconed, but probably just temporatly down |
(sorry for all the typos - it's late over here) | |
BrianH 12-Feb-2009 [11176] | It's weird, those sites were up last November. |
older newer | first last |