r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3-OLD1]

[unknown: 5]
12-Feb-2009
[11104x2]
But that isn't how the help stated it.  If it wanted me to pass the 
spec to the appy function it should have said so.
But it is still a function
BrianH
12-Feb-2009
[11106]
No, parameters evaluate unless they are specified with lit-words 
or get-words in REBOL. That is how all REBOL functions work.
[unknown: 5]
12-Feb-2009
[11107]
Why do we need Apply?
BrianH
12-Feb-2009
[11108]
Low-level code, special tricks, wrapper functions, safe evaluation, 
passing along refinements, ...
[unknown: 5]
12-Feb-2009
[11109x2]
Ok your right Brian, the help is perfect.
I haven't been programming in REBOL long enough to understand this 
stuff.
BrianH
12-Feb-2009
[11111x3]
I'll put in a ticket to change the help string from "Function to 
apply" to "Function value to apply", just in case.
It might even be accepted :)
Done.
Janko
12-Feb-2009
[11114]
huh.... I see rebol has many intereting words that I haven't even 
known about what even thought what they alow me to do .. like these 
that you mention apply and collect
[unknown: 5]
12-Feb-2009
[11115x2]
Brian, I'm not sure that value is a good term either - maybe others 
can comment.  I like to say spec.  As that makes more sense to me. 
 Newbies might think value means argument.  No matter how silly these 
 things seem - not everyone that is going to learn REBOL will have 
a programming background.
specification rather than spec.
BrianH
12-Feb-2009
[11117x3]
But you don't pass the function spec, you pass the function value. 
The function spec is the block with the parameters, types and doc 
strings. The function value is the value that gets assigned to the 
word that is used as the name of the function, it any.
it -> if
The function value is like :add, the function spec is (in R2) third 
:add or (in R3) spec-of :add.
>> print mold third :add
[
    "Returns the result of adding two values."
    value1 [number! pair! char! money! date! time! tuple!]
    value2 [number! pair! char! money! date! time! tuple!]
]
Janko
12-Feb-2009
[11120]
Brian .. some most certanly a crazy question ... is there a way you 
could walk/execute a block of code in steps ... this is probably 
possible (if they take no arguments)  [ func-1 func-2 func-3 ] ... 
but is there some "magic" way to execute make func consume their 
arguments, like this >> b: [ print "hello" add 4 6 ]<< and >>do get-expr 
b 1<< would print "hello" and >>do get-expr b 2<< would calcualate 
10 ... I know this is probably not even remotely possible
BrianH
12-Feb-2009
[11121]
Yes, DO/next. But it doesn't work in R3 yet, just R2. That is a bug, 
btw.
Janko
12-Feb-2009
[11122]
what is a bug?
BrianH
12-Feb-2009
[11123]
DO/next not working in R3. It's not an intentional change.
Janko
12-Feb-2009
[11124x2]
hm.. :) there really is do/next :)) awesome
aha... I was scared do/next is a bug :)
BrianH
12-Feb-2009
[11126x2]
DO was rewritten in R3, and not all of the old behavior is implemented 
yet. Though there are some intentional differences.
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
[11153]
what are pseudothreads?