Proposal: Relax rules for 'pure'
Don
nospam at nospam.com
Thu Sep 23 13:25:57 PDT 2010
Steven Schveighoffer wrote:
> On Thu, 23 Sep 2010 08:47:36 -0400, Robert Jacques <sandford at jhu.edu>
> wrote:
>
>> On Thu, 23 Sep 2010 02:51:28 -0400, Don <nospam at nospam.com> wrote:
>>
>>> Jesse Phillips wrote:
>>>> Steven Schveighoffer Wrote:
>>>>> If we can define weakly pure functions this way, they most likely
>>>>> will be way more common than unpure functions. I know I avoid
>>>>> accessing global variables in most of my functions. Think about a
>>>>> range, almost all the methods in a range can be weakly pure. So
>>>>> that means you need to mark every function as pure.
>>>
>>> I think that's true. I/O is impure, but most other things are not.
>>
>> The GC also impure :)
>
> The GC must be assumed to be pure even though it's not. Otherwise, pure
> functions can't do any heap allocation, and that makes them pretty
> useless in a garbage collected languages.
>
> In functional languages, allocating memory is usually considered pure.
In the D spec, it already says that 'new' is considered pure.
More information about the Digitalmars-d
mailing list