digitalmars.dip.ideas - Explcit impure function attribute
- Quirin Schroll (23/23) Jun 24 As I’m working getting the `@gc` function attribute into D, the
- Richard (Rikki) Andrew Cattermole (4/7) Jun 24 So add it.
- Quirin Schroll (8/16) Jun 26 So, you favor (effectively) adding `@impure`, and adding `@pure`
- Richard (Rikki) Andrew Cattermole (7/26) Jun 26 Yes.
- IchorDev (7/8) Jul 05 It might be a bit of a hassle to update, but since `pure` is a
- Richard (Rikki) Andrew Cattermole (4/10) Jul 05 I don't think it would be std.sumtype based.
As I’m working getting the ` gc` function attribute into D, the last remaining covariant attribute without contravariant inverse will be `pure`. The biggest question will not be how useful it is because its use will be exactly like that of other contravariant attributes (` system`, `throw`, and ` gc`), no, the biggest question is syntax. What are your preferences? A few inspirations: 1. Make `impure` a hard keyword, so `pure` and `impure` falls into the same syntactical category as `throw` and `nothrow`. This has the downside of breaking code that has identifiers named `impure`. I’d guess those would be rare, though. 2. Make ` impure` a compiler-recognized AtAttribute. This has the downside of being asymmetric: `pure` has no ` `, but its inverse ` impure` would have it. 3. Make `impure` a contextual keyword, i.e. a compiler-recognized identifier with special meaning in certain places, similar to `body`. This has the downside that it breaks very specific code (e.g. `int function() impure`) and that it uses contextual keywords which Walter really doesn’t like. This option is interesting for the base language when Option 1 is pursued in the next Edition. 4. ―???―
Jun 24
On 25/06/2024 4:38 AM, Quirin Schroll wrote:Make | impure| a compiler-recognized AtAttribute. This has the downside of being asymmetric: |pure| has no | |, but its inverse | impure| would have it.So add it. Deprecate, then remove without `` `` in newer editions. Making all attributes consistent with using `` `` is a good thing.
Jun 24
On Monday, 24 June 2024 at 16:47:06 UTC, Richard (Rikki) Andrew Cattermole wrote:On 25/06/2024 4:38 AM, Quirin Schroll wrote:So, you favor (effectively) adding ` impure`, and adding ` pure` as an alias for `pure`, while deprecating `pure`. Did I understand that correctly?Make ` impure` a compiler-recognized AtAttribute. This has the downside of being asymmetric: `pure` has no ` `, but its inverse ` impure` would have it.So add it. Deprecate, then remove without `` `` in newer editions.Making all attributes consistent with using `` `` is a good thing.There are still `throw` and `nothrow`. If I had to lay a bet on it, I’d say they don’t go anywhere. The value of replacing _them_ with something with ` ` is negligible.
Jun 26
On 27/06/2024 5:35 AM, Quirin Schroll wrote:On Monday, 24 June 2024 at 16:47:06 UTC, Richard (Rikki) Andrew Cattermole wrote:Yes. Get all the attributes to be the same, clean it up!On 25/06/2024 4:38 AM, Quirin Schroll wrote:So, you favor (effectively) adding ` impure`, and adding ` pure` as an alias for `pure`, while deprecating `pure`. Did I understand that correctly?Make ` impure` a compiler-recognized AtAttribute. This has the downside of being asymmetric: `pure` has no ` `, but its inverse ` impure` would have it.So add it. Deprecate, then remove without `` `` in newer editions.They'll both be going away at some point in favor of a throws set, to allow for value type exceptions. No other way to get the sumtype style exceptions working and there is significant desire by core developers for it.Making all attributes consistent with using `` `` is a good thing.There are still `throw` and `nothrow`. If I had to lay a bet on it, I’d say they don’t go anywhere. The value of replacing _them_ with something with ` ` is negligible.
Jun 26
It might be a bit of a hassle to update, but since `pure` is a keyword right now it'd be easy to just find-and-replace it with ` pure`, so I'm all for ` pure`, ` impure`, and no more `pure` keyword. On Wednesday, 26 June 2024 at 17:51:46 UTC, Richard (Rikki) Andrew Cattermole wrote:there is significant desire by core developers for it.So Phobos 3 will use SumType exceptions out of the gate?
Jul 05
On 05/07/2024 11:38 PM, IchorDev wrote:On Wednesday, 26 June 2024 at 17:51:46 UTC, Richard (Rikki) Andrew Cattermole wrote: there is significant desire by core developers for it. So Phobos 3 will use SumType exceptions out of the gate?I don't think it would be std.sumtype based. I do wish it was sumtype based however, but until that is in the language value type exceptions can't go in so we're a tad blocked atm.
Jul 05