> Hey...
>
> Given:
> name := "Jose Jimenez"
> every writes( ! name)
>
> The ! operator generates each letter of the string literal.
> So it dishes out one letter at a time to "write".
> "write" prints it.
>
> I don't see where "every" fits in? I realize that I'm not translating
> the code properly.
Every is a thing Demanding more results. If you say
writes(!name)
then ! will successfully yield the first letter of name, writes will write it,
and then the expression is complete.
"every" demands more results from it's expression.
In an example that still uses a string and ! check this:
write("b" == ! "abcabcabc")
The first character yielded by ! is "a", then it is given to ==
"b" == "a" is a fail, so it backtracks, because ALL expressions attempt to
complete once. Next character ! yields is "b" which is given to ==
"b" == "b" so it succeeds. The == operator happens to return it's right-value
"b" so that is given to write() and you'll see b on your console
At this point, the expression has succeeded once. The end of the statement is
reached, so it's all shut down, and the next statement in your code will be
run.
If, however, you had
every write("b" == ! "abcabcabc")
then b would be written 3 times on your console because every demands more
results until all possibilities are exhausted.
The suspend operation also happens to behave like every, so
procedure Bee()
suspend "b" == ! "abcabcabc"
end
in a procedure would cause the procedure to yield "b" three times. Which
happens to be what you want most of the time. It's up to the caller to decide
if it should be driven for more or not:
write(Bee()) # prints one "b" then closes off the suspended Bee proc
every write(Bee()) # prints "b" three times
[ps - i'm at my desk for another 2 hours then it's Beer o'clock and weekend
for me]
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Unicon-group mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/unicon-group