RFC, ensureHeaped
Steven Schveighoffer
schveiguy at yahoo.com
Tue Nov 16 20:53:04 PST 2010
On Tue, 16 Nov 2010 16:04:18 -0500, Jonathan M Davis <jmdavisProg at gmx.com>
wrote:
> On Tuesday 16 November 2010 12:37:10 bearophile wrote:
>> Jonathan M Davis:
>> > Pure is hard enough to deal with (especially since it we probably have
>> > made it the default, but it's too late for that now).
>>
>> Weakly pure on default isn't good for a language that is supposed to b e
>> somewhat compatible with C syntax, I think it breaks too many C
>> functions.
>
> Well, like I said, it's too late at this point, and really, it would be
> good to
> have a nice way to deal with C functions and purity (particularly since
> most of
> them are pure anyway), but the result at present is that most functions
> should
> be marked with pure. And if you're marking more functions with pure than
> not,
> that would imply that the default should be (at least ideally) impure.
> Regardless, however, it's not reasonable for D to go for impure rather
> than pure
> at this point.
everything you are saying seems to be backwards, stop it! ;)
1. currently, the default is impure.
2. Most functions will naturally be weakly pure, so making *pure* the
default would seem more useful.
It seems backwards to me to think pure functions should be the default, I
mean, this isn't a functional language! But you also have to forget
everything you know about pure, because a weakly pure function is a very
useful idiom, and it is most certainly not compatible with functional
languages. It's both imperative and can accept and return mutable data.
It makes me think that this is going to be extremely confusing for a
while, because people are so used to pure being equated with a functional
language, so when they see a function is pure but takes mutable data, they
will be scratching their heads. It would be awesome to make weakly pure
the default, and it would also make it so we have to change much less code.
-Steve
More information about the Digitalmars-d
mailing list