i add my description too hope its new :)

REBOL makes no destinction beetween data and program.
not to the user: you can edit text and you can load (do) text.
not to the program: it can edit blocks and load (do) blocks.

the "a:" should be seen as a "bookmark" in a block.
nothing more. in a functions it bookmarks into a part
of the function. if it changes its content, it changes
the function too. if you want to avoid it, you have
to tell the system "i need a new block". which can
be done by

copy "this string (or block or other series)"
or 
make string! 1000 ;empty string with 1000 char preallocated

when it comes to do code, the system can not decide
if a block is only read or changed to:

if something [some code]
print "this string"
change [datas here] 'code
yes-way: [some code] if something yes-way ...

and maybe one wishes to really change the function?
simply like c's "statics" or because of clever meta-hacks or
to keep scripts shorter? would need new sytax otherwise.

>> 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 ..)

or
repeat i 10 [append list: [] i]   probe list

you can collect scripts output with

>> &: func[s][append append "" s ", "]
>> & "this" & "that" third second :&
== "this, that, "

short :)

>> &: func[s][append append "" s ", "]
>> get-res: third second :& 3 ;change if '& changes!
== 3
>> & "this" & "that" res ;use it
== "this, that, "

safer. i remember to change 'get-res if you change  '& ..

>> &: func[s][append append res: "" s ", "]
>> & "this" & "that" res
== "this, that, "

better. should have thought before :)

other ways like auto-copy may break concepts i not
know yet.., and may be slower..

--
Volker

--- [EMAIL PROTECTED] wrote on 18-Aug-2000/10:09:43+10:00

> > > 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.
> 
> 
> 

Reply via email to