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: Combining m...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 10 of 16 Topic 2817 of 2841
Post > Topic >>

Re: Combining mutable objects with const references

by Paul Rubin <http://phr.cx@[EMAIL PROTECTED] > Apr 24, 2008 at 07:04 PM

anonposting@[EMAIL PROTECTED]
 writes:
> If there is a situation where persistence is required and can only
> be achieved efficiently ("minimizing copying") with a special data
> structure, then the imperative programmer can use that special data
> structure. He always has as many options as the functional
> programmer, structure-wise.

The functional programmer can similarly use mutable structures by
organizing the code so that the mutations can be modelled as actions
computed by function evaluation.  You basically treat the mutable
structure as if it were an I/O device.  The Haskell IO Array monads
are examples of this.  Using them is considered a bit icky since most
of the time they don't gain you much and it's better to use functional
structures, but the mutable versions are there if you need them, yet
the language still ensures that the messiness involved doesn't spread
outside of the limited scope that is actually typed to use the moand.

On a meta level, the notion that adding features to a language makes
it more capable is tempting but bogus.  Adding feature X might give
you the freedom to do X, but maybe what you really want is freedom
-from- X.  E.g., if your language has untyped memory pointers like C
or assembler, there is a huge class of bugs that your programs are no
longer necessarily free of.  Languages have to do more than ensure
that you can implement various desired program behaviors.  They also
should let you ensure the absence of undesired behaviors.  So good
language design is a balancing act of removing powerful but dangerous
features, and then using extreme cleverness (such as functional data
structures) to let you still accomplish your programming tasks with
what is left over after the dangerous stuff is removed.




 16 Posts in Topic:
Combining mutable objects with const references
anonposting@[EMAIL PROTEC  2008-04-22 07:32:52 
Re: Combining mutable objects with const references
=?ISO-8859-1?Q?Pertti_Kel  2008-04-22 23:23:43 
Re: Combining mutable objects with const references
anonposting@[EMAIL PROTEC  2008-04-23 06:12:53 
Re: Combining mutable objects with const references
anonposting@[EMAIL PROTEC  2008-04-23 14:05:57 
Re: Combining mutable objects with const references
torbenm@[EMAIL PROTECTED]  2008-04-24 09:35:17 
Re: Combining mutable objects with const references
=?ISO-8859-1?Q?Matti_Nyk=  2008-04-24 09:46:58 
Re: Combining mutable objects with const references
anonposting@[EMAIL PROTEC  2008-04-24 10:36:38 
Re: Combining mutable objects with const references
Paul Rubin <http://phr  2008-04-24 11:39:31 
Re: Combining mutable objects with const references
anonposting@[EMAIL PROTEC  2008-04-24 14:13:19 
Re: Combining mutable objects with const references
Paul Rubin <http://phr  2008-04-24 19:04:30 
Re: Combining mutable objects with const references
anonposting@[EMAIL PROTEC  2008-04-25 04:13:13 
Re: Combining mutable objects with const references
rossberg@[EMAIL PROTECTED  2008-04-25 06:57:19 
Re: Combining mutable objects with const references
Paul Rubin <http://phr  2008-04-25 09:42:29 
Re: Combining mutable objects with const references
anonposting@[EMAIL PROTEC  2008-04-26 05:38:40 
Re: Combining mutable objects with const references
anonposting@[EMAIL PROTEC  2008-04-26 06:07:26 
Re: Combining mutable objects with const references
rossberg@[EMAIL PROTECTED  2008-04-26 10:04:14 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Thu May 15 20:39:40 CDT 2008.