fbpx
Wikipedia

Lucid (programming language)

Lucid is a dataflow programming language designed to experiment with non-von Neumann programming models. It was designed by Bill Wadge and Ed Ashcroft and described in the 1985 book Lucid, the Dataflow Programming Language.[1]

Lucid
ParadigmDataflow
Designed byEdward A. Ashcroft
William W. Wadge
First appeared1976
Typing disciplineTypeless
Major implementations
pLucid, GIPSY
Dialects
Granular Lucid, Indexical Lucid, Tensor Lucid, Forensic Lucid, Lucx, JOOIPL
Influenced by
ISWIM
Influenced
SISAL, PureData, Lustre

pLucid was the first interpreter for Lucid.

Model edit

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' (read as 'followed by') 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 conceived as a disciplined, mathematically pure, single-assignment language, in which verification would be simplified. However, the dataflow interpretation has been an important influence on the direction in which Lucid has evolved.

Details edit

In Lucid (and other dataflow languages) an expression that contains a variable that has not yet been bound waits until the variable has been 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 consequence of this is that explicit logic for updating related values is avoided, which results in substantial code reduction, compared to mainstream languages.

Each variable in Lucid is a stream of values. An expression n = 1 fby n + 1 defines a stream using the operator 'fby' (a mnemonic for "followed by"). fby defines what comes after the previous expression. (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 makes a true value available. (It serves to slow down the stream x) i.e.: 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-varying streams of data.

Examples edit

Factorial edit

fac where n = 0 fby (n + 1); fac = 1 fby ( fac * (n + 1) ); end 

Fibonacci sequence edit

fib where fib = 0 fby ( 1 fby fib + next fib ); end 

Total of a Sequence edit

total where total = 0 fby total + x end; 

Running Average edit

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

Prime numbers edit

prime where prime = 2 fby (n whenever isprime(n)); n = 3 fby n+1; 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 edit

 

Quick sort edit

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 edit

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

Root mean square edit

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 edit

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 edit

 
Hamming problem dataflow diagram

References edit

  1. ^ Wadge, William W.; Ashcroft, Edward A. (1985). Lucid, the Dataflow Programming Language. Academic Press. ISBN 0-12-729650-6. Retrieved 8 January 2015.

External links edit

  • pLucid

lucid, programming, language, lisp, software, company, lucid, this, article, relies, excessively, references, primary, sources, please, improve, this, article, adding, secondary, tertiary, sources, find, sources, lucid, programming, language, news, newspapers,. For the Lisp software company see Lucid Inc This article relies excessively on references to primary sources Please improve this article by adding secondary or tertiary sources Find sources Lucid programming language news newspapers books scholar JSTOR April 2018 Learn how and when to remove this message Lucid is a dataflow programming language designed to experiment with non von Neumann programming models It was designed by Bill Wadge and Ed Ashcroft and described in the 1985 book Lucid the Dataflow Programming Language 1 LucidParadigmDataflowDesigned byEdward A AshcroftWilliam W WadgeFirst appeared1976Typing disciplineTypelessMajor implementationspLucid GIPSYDialectsGranular Lucid Indexical Lucid Tensor Lucid Forensic Lucid Lucx JOOIPLInfluenced byISWIMInfluencedSISAL PureData Lustre pLucid was the first interpreter for Lucid Contents 1 Model 2 Details 3 Examples 3 1 Factorial 3 2 Fibonacci sequence 3 3 Total of a Sequence 3 4 Running Average 3 5 Prime numbers 3 5 1 Dataflow diagram 3 6 Quick sort 3 6 1 Data flow diagram 3 7 Root mean square 3 8 Hamming problem 3 8 1 Dataflow Diagram 4 References 5 External linksModel editLucid 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 read as followed by 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 conceived as a disciplined mathematically pure single assignment language in which verification would be simplified However the dataflow interpretation has been an important influence on the direction in which Lucid has evolved 1 Details editIn Lucid and other dataflow languages an expression that contains a variable that has not yet been bound waits until the variable has been 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 consequence of this is that explicit logic for updating related values is avoided which results in substantial code reduction compared to mainstream languages Each variable in Lucid is a stream of values An expression n 1 fby n 1 defines a stream using the operator fby a mnemonic for followed by fby defines what comes after the previous expression 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 makes a true value available It serves to slow down the stream x i e 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 varying streams of data Examples editFactorial edit fac where n 0 fby n 1 fac 1 fby fac n 1 end Fibonacci sequence edit fib where fib 0 fby 1 fby fib next fib end Total of a Sequence edit total where total 0 fby total x end Running Average edit running avg where sum first input fby sum next input n 1 fby n 1 running avg sum n end Prime numbers edit prime where prime 2 fby n whenever isprime n n 3 fby n 1 isprime n not divs asa divs or prime prime gt N where N is current n divs N mod prime eq 0 end end Dataflow diagram edit nbsp Quick sort edit qsort a if eof first a then a else follow qsort b0 qsort b1 fi where p first a lt 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 edit gt whenever gt qsort not gt first V gt less V V gt whenever gt qsort gt conc gt ifthenelse gt gt next gt first gt iseod Root mean square edit 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 lt 0 0001 where Z is current z approx Z 2 fby approx Z approx 2 err abs square approx Z end end Hamming problem edit h where h 1 fby merge merge 2 h 3 h 5 h merge x y if xx lt yy then xx else yy fi where xx x upon xx lt yy yy y upon yy lt xx end end Dataflow Diagram edit nbsp Hamming problem dataflow diagramReferences edit Wadge William W Ashcroft Edward A 1985 Lucid the Dataflow Programming Language Academic Press ISBN 0 12 729650 6 Retrieved 8 January 2015 External links editpLucid Retrieved from https en wikipedia org w index php title Lucid programming language amp oldid 1141612150, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.