[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can a functional language be sequential?
Dan Sugalski wrote:
> At 12:53 PM -0400 6/2/03, Michael St . Hippolyte wrote:
>
>> On 2003.06.01 17:13 andrew cooke wrote:
>>
>>>
>>> as far as i can tell, your programs do have side effects, just as many
>>> functional programs have side effects - they change the state of the
>>> "world" by doing output operations. since the order of output is
>>> generally important, functional languages need to sequence events just
>>> as much as imperative ones. (ok, i know you probably meant side
>>> effects within the program).
>>
>>
>> Yes, Bento connects very easily to the outside world, and once you do
>> side effects are unavoidable. This would be true of any functional
>> language capable of calling external methods, no? I'm assuming that
>> such real-world exceptions are accepted by real-world functional
>> programmers -- it would be hard to do many useful things otherwise.
>
>
> It might be interesting to have a way to mark individual functions as
> having side-effects or not, with upward propagation of that mark, so the
> compiler and/or runtime would be able to tell which parts of the program
> are order-free and which parts need to maintain ordering. While it
> doesn't touch directly on your problem, having this information handy at
> runtime would give the execution engine more information about what has
> to be done in what order, which may give you some potential wins for
> optimization.
In the language we defined for insurance rating, there were two "realms":
the functional realm and the procedural. Procedures could call functions
but functions could not call procedures. So, once you were in the
"functional realm",
you couldn't produce any side effects. Initially, the users thought that
would be too limiting but they discovered that it was generally pretty easy
to pull the side effects "outside" of the bulk of their code. Most of
the code
was within the functional realm and the outer shell was mainly concerned
with
reading and writing to/from a database. With sufficient built-in support
for sequences and tuples/records, most of the other uses of side effects
turned
out to be non-issues.
--Jerry