Requiring weak purity for opAssign, postblit

spir denis.spir at gmail.com
Sat Dec 25 12:19:17 PST 2010


On Sat, 25 Dec 2010 18:46:17 +0000 (UTC)
Tomek Sowiński <just at ask.me> wrote:

> dsimcha <dsimcha at yahoo.com> wrote:
> > I've been thinking about adding purity to various parts of Phobos and
> > one
> > thing that limits this in the case of containers is templated
> > containers,
> > arrays, etc. that may be instantiated with a user-defined type.  In
> > theory,
> > even assigning/copying a user-defined type could be impure.  Does
> > anyone see a
> > problem with requiring opAssign and postblits to be weakly pure to
> > solve this
> > problem?
> 
> I guess a postblit could obtain a "new" instance by taking one off a
> freelist.
> 
> From bird's eye, the more code I write with the new pure design the more
> these two thoughts get reinforced:
> 
> 1. Technically speaking it's excellent, solves quite a bit.
> 2. Functions ought to be weakly pure by default (please don't dismiss as
> bikeshedding). It's the most common case by a large margin. Plus,
> functions that do use globals need more attention from reviewers, so
> making *them* greppable saves time.

@sinner functions ;-)

Denis



-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the Digitalmars-d mailing list