Lucid (programming language)

Lucid (programming language)

Infobox programming language
name = Lucid
logo =
paradigm = Dataflow
year = 1976
designer = Edward A. Ashcroft,William W. Wadge
developer = ,Wadge
latest release version =
latest release date =
typing = Typeless
implementations = pLucid
dialects = GIPSY GLU
influenced_by = ISWIM
influenced = SISAL, PureData, Lustre
Lucid is a dataflow programming language. It is designed to experiment with non-von Neumann programming models. It was designed by Bill Wadge and Ed Ashcroft and described in the book "Lucid, the Dataflow Programming Language".

Model

Lucid uses a demand-driven model for data computation. Each statement can be understood as an equation defining a network of processors and communication lines between them through which data flows. Each variable is an infinite stream of values and Every function is a filter or a transformer. Iteration is simulated by 'current' values and 'fby' operator allowing composition of streams.

Lucid is based on an algebra of histories, a history being an infinite sequence of data items. Operationally, a history can be thought of as a record of the changing values of a variable, history operations such as first and next can be understood in ways suggested by their names. Lucid was originally thought of as a kind of very disciplined mathematically pure single assignment language in which verification would be very much simplified. However, the dataflow interpretation has been very important in helping the direction in which Lucid has evolved. [http://www.chilton-computing.org.uk/acd/dcs/projects/p026.htm]

Details

In Lucid (and other dataflow languages) an expression that contains a variable that was not yet bound waits until the variable is bound before proceeding. An expression like x + y will wait until both x and y are bound before returning with the output of the expression. An important result of this is that explicit logic for updating related values is avoided, which results in substantial code reduction compared to mainstreamlanguages.

Each variable in Lucid is a stream of values. An expression n = 1 fby n + 1 defines a streamusing the operator 'fby'. fby (read as 'followed by') defines what comes after the previousexpression. (In this instance the stream produces 1,2,3,...).The values in a stream can be addressed by these operators (assuming x is the variable being used):

'first x' - fetches the first value in the stream x,

'x' - the current value of the stream,

'next x' - fetches the next value in the stream.

'asa' - an operator that does some thing 'as soon as' the condition given becomes true.

'x upon p' - upon is an operator that repeats the old value of the stream x, and updates to the new values only when the stream p makesa true value available. (It serves to slow down the stream x) ie: x upon p is the stream x with new values appearing upon the truth of p.

The computation is carried out by defining filters or transformation functions that act on these time-varyingstreams of data.

pLucid was the first interpreter for Lucid.

Examples

Total of a Sequence

total where total = 0 fby total + x end;

Running Average

running_avg where sum = first(input) fby sum + next(input); n = 1 fby n + 1; running_avg = sum / n; end;

Prime Numbers

[http://i.csc.uvic.ca/home/hei/lup/02.html]

prime where prime = 2 fby (n whenever isprime(n)); n = 3 fby n+2; isprime(n) = not(divs) asa divs or prime*prime > N where N is current n; divs = N mod prime eq 0; end; end

Dataflow Diagram

---+1<--- -->isprime----
|
| V ->fby--------------->whenever---> ^
2

Quick Sort

[http://i.csc.uvic.ca/home/hei/lup/06.html]

qsort(a) = if eof(first a) then a else follow(qsort(b0),qsort(b1)) fi where p = first a < a; b0 = a whenever p; b1 = a whenever not p; follow(x,y) = if xdone then y upon xdone else x fi where xdone = iseod x fby xdone or iseod x; end end

Data flow Diagram

--------> whenever -----> qsort ---------
^
|
not
^
---> first |
| |
V |
---> less ---
|
V V ---+--------> whenever -----> qsort -----> conc -------> ifthenelse ----->
^ ^
|
--------> next ----> first ------> iseod --------------

-----------------------------------------------------------

quare Root

sqroot(avg(square(a))) where square(x) = x*x; avg(y) = mean where n = 1 fby n+1; mean = first y fby mean + d; d = (next y - mean)/(n+1); end; sqroot(z) = approx asa err < 0.0001 where Z is current z; approx = Z/2 fby (approx + Z/approx)/2; err = abs(square(approx)-Z); end; end

Hamming Problem

[http://i.csc.uvic.ca/home/hei/lup/01.html]

h where h = 1 fby merge(merge(2 * h, 3 * h), 5 * h); merge(x,y) = if xx <= yy then xx else yy fi where xx = x upon xx <= yy; yy = y upon yy <= xx; end; end;

Dataflow Diagram

--------------------*2---------
-------------*3---------
| --*5---------
| |
V V
--->merge----->merge----->fby--------> ^
1

External links

* [http://code.google.com/p/plucid/ pLucid]
* [http://c2.com/cgi/wiki?LucidLanguage Language overview]
* [http://hopl.murdoch.edu.au/showlanguage2.prx?exp=960 Evolution of Lucid]
* [http://i.csc.uvic.ca/home/hei/hei.ise Bill Wadge's home page]
* [http://www.artima.com/weblogs/viewpost.jsp?thread=102839 Fluid Programming in Lucid]
* [http://www.haskell.org/haskellwiki/Lucid Lucid page of HaskellWiki]
* [http://i.csc.uvic.ca/home/hei/lup/contents.html Programming in Lucid]
* [http://i.csc.uvic.ca/home/hei/ei/contents.ise An Eductive Interpreter]
* [http://i.csc.uvic.ca/home/LucidPrimer/LPS.ise Lucid Primer]
* [http://newton.cs.concordia.ca/~gipsy/ GIPSY]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • Lucid — may refer to: * LUCID Detector (ATLAS Luminosity Monitor), a high energy physics detector * Lucid (programming language), a dataflow programming language * Lucid (software) [http://www.cbit.uq.edu.au/software/LucidID/default.htm] is a software… …   Wikipedia

  • Lucid Inc. — Lucid Incorporated was a software development company founded by Richard P. Gabriel in 1984, which went bankrupt in 1994. BeginningsGabriel had been working for Lawrence Livermore National Labs on a computer hardware project called S1 , the first …   Wikipedia

  • List of programming languages by category — Programming language lists Alphabetical Categorical Chronological Generational This is a list of programming languages grouped by category. Some languages are listed in multiple categories. Contents …   Wikipedia

  • Dataflow programming — Programming paradigms Agent oriented Automata based Component based Flow based Pipelined Concatenative Concurrent computing …   Wikipedia

  • List of programming languages — Programming language lists Alphabetical Categorical Chronological Generational The aim of this list of programming languages is to include all notable programming languages in existence, both those in current use and historical ones, in… …   Wikipedia

  • English language — Language belonging to the Germanic languages branch of the Indo European language family, widely spoken on six continents. The primary language of the U.S., Britain, Canada, Australia, Ireland, New Zealand, and various Caribbean and Pacific… …   Universalium

  • Dynamic Language Runtime — Developer(s) Microsoft Dynamic Language Runtime Team Stable release 1.0 / April 16, 2010 Operating system Microsoft Windows, Debian, Ubuntu Platform …   Wikipedia

  • Dataflow — This article is about software engineering. For the flow of data within a computer network see packet flow For the graphical representation of flow of data within an information system, see data flow diagram Dataflow is a term used in computing,… …   Wikipedia

  • Common Lisp — Paradigm(s) Multi paradigm: procedural, functional, object oriented, meta, reflective, generic Appeared in 1984, 1994 for ANSI Common Lisp Developer ANSI X3J13 committee Typing discipline …   Wikipedia

  • Emacs — infobox software caption = GNU Emacs 22.0.91.1 with multiple buffers and syntax highlighting for LaTeX, C#, and C. developer = the GNU project author = Richard Stallman released = release year|1976 frequently updated = yes programming language =… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”