Kinds of containers

Ice Cream Man via Digitalmars-d digitalmars-d at puremagic.com
Wed Oct 21 08:18:07 PDT 2015


On Wednesday, 21 October 2015 at 14:06:43 UTC, Jonathan M Davis 
wrote:
>> 1. Functional containers.
>
> I fully expect that these have their place, but I honestly have 
> no idea what they would be. When I've used functional 
> languages, I've only ever found these attributes to be a royal 
> pain to deal with, not a benefit. From what I've seen, 
> containers are the sort of thing that almost always always need 
> to be mutable to be of any real benefit. Upon occasion, 
> constructing a container up front and then never tweaking it 
> after that is useful, but that's pretty rare from what I've 
> seen.
>
> The only cases that I can think of where this could be really 
> beneficial would be something like strings, and we're using 
> arrays for those currently (though they are arguably functional 
> containers given that they have immutable elements).

I've found immutable containers useful when working with 
configuration files. There are only a few places in a program 
where you want to actively change values in a configuration files 
(configure the values). For these instances it's useful for the 
GUI or whatever to grab a mutable container to work with. For all 
other areas, immutable containers are very helpful in ensuring 
nobody accidentally modifies something they shouldn't be outside 
of the provided sandboxes.


More information about the Digitalmars-d mailing list