Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.haskell > #347
| From | Unknown <dog@gmail.com> |
|---|---|
| Newsgroups | comp.lang.haskell |
| Subject | Re: How(approaches) to implement implementing lazy evaluation in the C (Imperative Programming) |
| Date | 2015-10-17 06:38 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <pan.2015.10.17.06.44.09@gmail.com> (permalink) |
| References | <07c4a873-63a7-4a3a-9318-d0baf50f099f@googlegroups.com> <5efd887b-e5e8-48f5-bab6-e695c425909a@googlegroups.com> |
On Sat, 19 Sep 2015 11:35:06 -0700, fmassei wrote:
> On Friday, September 18, 2015 at 4:37:14 PM UTC+2, Nandhan wrote:
>> Hello Sir,
>>
>> How to implement implementing lazy evaluation in the C (Imperative
>> Programming)?
>>
>> Lazy evaluation is one of the key features in functional programming
>> languages such as Haskell. This feature allows the programmers to work
>> on infinite series quite easily. Functional programming languages work
>> at higher abstraction focusing on what needs to be done instead of on
>> how it can be done.
>>
>> Imperative programming languages focus more on how a goal can be
>> achieved and hence work at a lower level of abstraction. Therefore, it
>> is natural to ask how such a feature can be implemented in imperative
>> programming languages such as C.
>>
>> What are the Various Approaches of implementing lazy evaluation in the
>> C programming language.
>>
>> What are the Constructs required for implementing lazy evaluation logic
>> 'C' programming language support for the required constructs
>> Thanks Sir
>>
>>
> (First of all, how is this related to Haskell? Wouldn't comp.theory or
> comp.lang.c be better NGs for this question?)
>
> I will read you question as "is there a fast/quick way to implement a
> sort of lazy evaluation in C?", because if you're searching a more
> general answer, like "how does a compiler of functional language work?",
> well, you're asking about more than half of the whole computer
> technology theory, and I will just suggest you to start reading.
>
> In C I would probably never even try to do it, but if it's just for
> having some sort of fun, I'd go by implementing a coroutine mechanism
> and generators on top. Both of them are somehow tricky but not difficult
> to write, and sometimes they can even be a reasonable solution for a
> certain set of problems.
>
> Ciao!
It seems to me that lazy evaluation is not the big advantage of haskell.
A relevant extract from my:
Newsgroups: comp.lang.oberon
Subject: Functional programming style for Oberon?
is:
A most convincing argument, for me, for the functional style, is:--
Let's create a list of all even numbers up to 100, and another list
omitting the first five of them.
The program written in Java.
final int LIMIT=50;int[] a = new int[LIMIT];
int[] b = new int[LIMIT - 5];
for (int i=0;i < LIMIT;i++) {
a[i] = (i+1)*2;
if (i >=5) b[i - 5] = a[i];
}
The program written in ###
let a = [2,4..100]
let b = drop 5 a
It is immediately clear that with ###, you can understand what's
going on; whereas in Java, or any imperative language, you can barely
tell what the code is supposed to do because you are overwhelmed with
the low-level minutia. This effect increases as programs grow more
complex. From this simplicity and abstraction flow most of ###'s
advantages.
----------------------------- end of extract. --------------------
There's nothing new about this. Extracting from McCarthy [designed lisp
in 60s?]:-
These three procedures clearly share a common underlying pattern. They
are for the most part identical, differing only in the name of the
procedure, the function/job of a used to compute the term to be added,
and the function that provides the next value of a. We could generate
each
of the procedures by filling in slots in the same template:
------ snip lisp code ---
The presence of such a common pattern is strong evidence that there is
a useful abstraction waiting to be brought to the surface. Indeed,
mathematicians long ago identified the abstraction of summation of a
series and invented ``sigma notation,''
to express this concept. The power of sigma notation is that it allows
mathematicians to deal with the concept of summation itself rather
than only with particular sums -- for example, to formulate general
results about sums that are independent of the particular series being
summed ...
Back to comp.lang.haskell | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How(approaches) to implement implementing lazy evaluation in the C (Imperative Programming) Chethan U <evolutionmanager123@gmail.com> - 2015-09-18 07:37 -0700
Re: How(approaches) to implement implementing lazy evaluation in the C (Imperative Programming) fmassei@gmail.com - 2015-09-19 11:35 -0700
Re: How(approaches) to implement implementing lazy evaluation in the C (Imperative Programming) Unknown <dog@gmail.com> - 2015-10-17 06:38 +0000
Re: How(approaches) to implement implementing lazy evaluation in the C (Imperative Programming) Steven Hystad <steven.hystad@lunarinfrastructure.net> - 2015-09-19 23:50 -0600
Re: How(approaches) to implement implementing lazy evaluation in the C (Imperative Programming) He-chien Tsai <depot051@gmail.com> - 2015-11-07 08:17 -0800
csiph-web