Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Oz (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Dataflow variables and declarative concurrency === When the program encounters an unbound variable it waits for a value. For example, below, the thread will wait until both X and Y are bound to a value before showing the value of Z. <syntaxhighlight lang="erlang"> thread Z = X+Y {Browse Z} end thread X = 40 end thread Y = 2 end </syntaxhighlight> The value of a dataflow variable cannot be changed once it is bound: <syntaxhighlight lang="erlang"> X = 1 X = 2 % error </syntaxhighlight> Dataflow variables make it easy to create concurrent stream agents: <syntaxhighlight lang="erlang"> fun {Ints N Max} if N == Max then nil else {Delay 1000} N|{Ints N+1 Max} end end fun {Sum S Stream} case Stream of nil then S [] H|T then S|{Sum H+S T} end end local X Y in thread X = {Ints 0 1000} end thread Y = {Sum 0 X} end {Browse Y} end </syntaxhighlight> Because of the way dataflow variables work, it is possible to put threads anywhere in a program and guaranteed that it will have the same result. This makes concurrent programming very easy. Threads are very cheap: it is possible to have 100,000 threads running at once.<ref>{{Cite web |url=http://www.mozart-oz.org/documentation/tutorial/node8.html#chapter.concurrency |title=Archived copy |access-date=29 November 2008 |archive-url=https://web.archive.org/web/20150224185115/http://www.mozart-oz.org/documentation/tutorial/node8.html#chapter.concurrency |archive-date=24 February 2015 |url-status=usurped }}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)