[REBOL] problems with local vars??? Re:(5)

2000-08-18 Thread galtbarber

To Andrew:
 why do you say that rebol functions 
are a kind of rebol dialect?

I thought they were more of a built-in type function!
There are some special things that happen in a function
that are all about binding params and locals,
but I would be surprised if functions worked internally 
like the dialect that is in parse or view.
If it works that way, it's a sheer revelation
to me.  In fact, how could you define a dialect 
without referring to other functions?
Is that a chicken and egg kind of thing?

To Everybody:
 in the examples given in this thread, 
there is none showing this obvious one using /local with func:

somefunc: func [
 n [integer!]
 /local tmp
][
 tmp: n * n
 ;;; snipped rest of code ...
]

I believe that internally 'function will just 
end up calling 'func and passing the block of 
locals as /local.  If you make yourself a function f
with 'function and then look at first :f, second :f
and third :f, you will see that in first :f there 
is the param list with the locals defined with /local.

I think this change appeared with Rebol2.

-Galt

p.s. although Rebol may be "interpreted",
the body and params and etc. have been fully 
"load"-ed and that means they are like typed 
tokens and bound words that are ready to roll.

It's not like a lot of simple interpreters which are converting 
straight from source as just a string of characters
for each and every line.

when the function definition is executed 
that baby creates the function! value and 
assigns it to the function's name word,
and that value sure isnt just a string! of code.

so that makes sense and the interpreter can run 
pretty fast.  I am sure that it is the same 
with Logo, Lisp, Scheme, etc...  I think the 
series type is also something that helps make 
Rebol fast.  I don't recall seeing its like 
in those other cousins of Rebol.

-Galt

>= Original Message From [EMAIL PROTECTED] =
>Brett wrote:
>> But I wonder if Rebol necessarily sees functions like this? Are they
>perhaps a dialect that is interpreted?
>
>Rebol functions are a dialect and they are interpreted.
>
>Andrew Martin
>ICQ: 26227169
>http://members.xoom.com/AndrewMartin/
>-><-




[REBOL] problems with local vars??? Re:(5)

2000-08-18 Thread bhandley

Guru question.

Rebol functions are a dialect which is interpreted...
[ ]  At load time.
[ ]  After being loaded.
[ ]  Both of the above.
[ ]  The question is irrelevent and can be ignored without harm.
[ ]  Not enough information to say.
[ ]  Other (please specify). 

;)
Brett


- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, August 18, 2000 3:43 PM
Subject: [REBOL] problems with local vars??? Re:(4)


> Brett wrote:
> > But I wonder if Rebol necessarily sees functions like this? Are they
> perhaps a dialect that is interpreted?
> 
> Rebol functions are a dialect and they are interpreted.
> 
> Andrew Martin
> ICQ: 26227169
> http://members.xoom.com/AndrewMartin/
> -><-
> 




[REBOL] problems with local vars??? Re:(5)

2000-08-18 Thread agem


--- [EMAIL PROTECTED] wrote on 18-Aug-2000/13:37:06+1:00
> 
> i add my description too hope its new :)
> ...

> >> repeat i 10 [append [] i]
> == [1 2 3 4 5 6 7 8 9 10]
> 
> ( do copy [repeat i 10 [append [] i] ] ; in a function ..)
> 

do copy/deep [repeat i 10 [append [] i] ] ; in a function ..

copy/deep of course..

Volker




[REBOL] problems with local vars??? Re:(5)

2000-08-17 Thread Al . Bri

Paul wrote:
> Is three blocks proper syntax for a function?

MyFunc: func [Args] [print Args]
MyFunction: function [Args] [Locals] [Locals: Args print [locals
args]]
MyDoes: does [print "No args or locals"]

Yes.

I hope that helps!

Andrew Martin
ICQ: 26227169
http://members.xoom.com/AndrewMartin/
-><-




[REBOL] problems with local vars??? Re:(5)

2000-08-17 Thread rryost

3 blocks is ok as can be seen by
>> help function

Russell [EMAIL PROTECTED]
- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 17, 2000 5:58 PM
Subject: [REBOL] problems with local vars??? Re:(4)


> Is three blocks proper syntax for a function?
>
> Paul Tretter
>
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 17, 2000 7:10 PM
> To: [EMAIL PROTECTED]
> Subject: [REBOL] problems with local vars??? Re:(3)
>
>
> > > Here's your function slightly edited
> > >
> > > local-func: function [input][my-local-string][
> > > my-local-string:  ; This says make it so that my-local-string
> refers
> > > to the next value. (1)
> > > "that is local " ; This says create a string value. (2)
> > > print append my-local-string input; (3)
> > > ]
> > >
> >
> > I think it's slightly confusing to say in (2) that the literal string
> > "says to create a string value".  Instead, I suggest that in (2) the
> > literal string IS a string value.  (If I had my geek hat on, I'd say
> > something more complicated like "serves as a reference to the string
> > that was created when this source code was loaded", bit I left my geek
> > hat at home today... ;-)
>
> Yeah, it probably is a bit confusing. I confused my contexts. I intended
to
> to convey the sense that Rebol "does it differently", especially compared
to
> a compiled language (which was the example), rather than attempting to
> explain the deepest truths behind Rebol (which I'm not entirely confident
> on). I should have made that clear. I sould have also made clear that my
> meaning referred to what happens at load - distinguishing between might
> happen when Rebol script is parsed as opposed to when Rebol values are
> evaluated.
>
> > Every time the function referred to by to local-func is evaluated,
> > my-local-string is set to refer to THE SAME STRING, rather than a
> > newly-created one.
>
> This sounds like a nice description when you have the expectation that
> functions always do something (their definitions) when they are evaluated.
> That they carry out all the parts of their definition when evaluated. A
way
> of thinking that says "this function now has program control" so it has to
> do something (which is quite reasonable to imagine). But I wonder if Rebol
> necessarily sees functions like this? Are they perhaps a dialect that is
> interepreted? I only ask this because I'm trying to shake of my normal
> assumptions of what Rebol is doing when it evaluates a "function" which is
> after all a Rebol value not something like machine instructions (another
> guess!).
>
> >  Therefore, mutations on the value of my-local-string
> > (e.g., append, insert, remove, replace ) are continuing to operate
> > on the same string which ORIGINALLY (at load time) contained
> > "that is local ", but which has subsequently been modified with every
> > evaluation of the function.
> >
> > I don't want to sound hypercritical here!  I'm really just thinking
> > out loud about how to describe the behavior of literal series values
> > in REBOL, as this sort of thing keeps coming up on the list.
>
> Yes, I know. I've collected three useful descriptions of it on my tips
page.
> But I feel that at least two levels of description (absolute beginner/ not
> an absolute beginner) could be useful - differentiated perhaps by one
using
> metaphor and the other describing "the truth"...
>
> > You certainly described the correct solution in the remainder of your
> > note, but I'm wondering if making a more explicit distinction between
> > load time and evaluation time will help us explain this.
>
> Well, I think Elan can tell you that he believes it would since this
> distinction is made in "The Official Guide" (p230).
>
> Brett.
>