Steve Graham wrote:
> Why did this program work with while substituted for every?  Is the 
> string still not an immutable type?

In case Clint is busy...

In the original line:

    every fnd := find("lu", astring) do {

the use of every means that there is no looping
taking place.  Instead goal-directed evaluation
is used to backtrack through the generators in
the control expression to produce all results from
those generators.  The only generator that can
produce more than one result in the above
is the find(), so there's no backtracking
beyond that point that would cause the
dereferencing of the variable astring to
be repeated.  This means you'll only see
the results that find generates from
the original value of astring.

In the second case:

    while fnd := find("lu", astring) do {

only the first value generated by find is
used each time through the loop and the
entire expression is evaluated anew on
each iteration.  So astring gets dereferenced
every time and find gets called with the
new value of astring each time.

(Incidently, remove the "astring := astring" line
at the end of the loop.  It's not doing anything.)
-- 
Steve Wampler -- [email protected]
The gods that smiled on your birth are now laughing out loud.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Unicon-group mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to