digitalmars.D - Re: Purity
- bearophile <bearophileHUGS lycos.com> Mar 24 2011
Bruno Medeiros:I think that the concession that pure will be allowed to allocate memory does inescapably remove some of the guarantees that pure functions offer (like that one that the return value depends only on the arguments). One possible fix to this would be to say that the allocated memory must be temporary (used only during the execution of the pure function). Thus you would not be able to return any newly-allocated value. But I don't know if this further restriction is desirable or not. I don't remember if this aspect of memory allocation in pure functions was discussed/thought-out extensively or not. (it probably needs to)
I have discussed this a bit with Steven Schveighoffer, see the transparent attribute, in this "Uh... destructors?" thread: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=130554 Bye, bearophile
Mar 24 2011