Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Functional > Re: How to avoi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 5 Topic 2824 of 2841
Post > Topic >>

Re: How to avoid side effects following functional style, when you

by salog <alesmaer@[EMAIL PROTECTED] > May 1, 2008 at 11:44 PM

On 29 =AC=D1=AC=E1=AC=E2, 23:48, torb...@[EMAIL PROTECTED]
 (Torben =A8=A1gidius
=
Mogensen)
wrote:
> I'm not exactly sure what you mean.  Do you mean that a0 takes b0 as
> an extra argument and vice versa?  

Exactly.

> I don't see what this would
> accomplish, except as a kind of comment reminding readers that they
> are linked.  

Not only. Database objects are linked with no direction and with no
order.
These features should be defined in the program only.

> And the important linkage isn't really in the functions
> you use, but in the objects they access.  For example, a function that
> reads from a file may be used on many different files, and what the
> write-to-file function needs is not knowing that a read-from-file
> function exists (or the identity of this), but what files are
> currently open for reading.

We can write this code in imperative manner :

   FileWrite(data, FileOpen('text.txt'));

It means, that the file should be opened before it's written. In other
words we define dependence FileWrite() upon FileOpen().

Next case is when we have double dependence:

   FileRead(FileWrite(data, FileOpen('text.txt')) ,
FileOpen('text.txt') );

It means, that we want to be sure that we read data just after they
are written to the file, and also, we need that the file is open.

In imperative language FileOpen('text.txt') will be called twice. I
hope, that functional compiler is able to understand the idea about
declaring dependence and to call (and then to save result)
FileOpen('text.txt') once.

> Besides, making a function require a specific other function as
> argument requires some trickery with types, essentially inventing a
> type unique to that specific function.  Also, this becomes more
> complicated if you have more than two functions that interact with the
> same stateful object.  For example, to interact with a file, you need
> functions to open, close, read from and write to the file and,
> possibly, move the read or write focus.

I am not familiar with functional languages yet (I am just walking
around). That's why I don't know what formal methods or syntax can be
used to convey the idea about function's dependences to the compiler.
Only new type definition? It's really inconveniently. A special
operator would be good for use, if it not exists yet, I think.




 5 Posts in Topic:
How to avoid side effects following functional style, when you n
salog <alesmaer@[EMAIL  2008-04-28 20:02:07 
Re: How to avoid side effects following functional style, when y
torbenm@[EMAIL PROTECTED]  2008-04-29 09:51:14 
Re: How to avoid side effects following functional style, when y
salog <alesmaer@[EMAIL  2008-04-29 01:24:38 
Re: How to avoid side effects following functional style, when y
torbenm@[EMAIL PROTECTED]  2008-04-29 14:48:54 
Re: How to avoid side effects following functional style, when y
salog <alesmaer@[EMAIL  2008-05-01 23:44:13 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 2:35:43 CDT 2008.