Crow programming language

IchorDev zxinsworld at gmail.com
Thu Feb 15 15:24:37 UTC 2024


On Thursday, 15 February 2024 at 04:32:27 UTC, andy wrote:
> * Having to write `@safe @nogc pure nothrow` all the time. It 
> needs a way to make that the default and mark specific things 
> as not-safe or not-pure.

You can make a scope with `nothrow`, `@nogc`, etc.:
```d
nothrow @nogc pure @safe{
void fn1(){}
void fn2(){}
void fn3(){}
}
```

> A pattern matching syntax for D could make this prettier.

I think Walter has a draft DIP for "sumtype"s with pattern 
matching.
I really wish this would be added soon.

> One annoyance with pure code is having to pass `AllSymbols`, 
> the symbol (interned string) table, to any function that needs 
> to create a symbol or un-intern it. I think using this through 
> a global variable could be considered pure, since a caller to 
> `symbolOfString` can't tell whether the symbol has been added 
> or not, and the `stringOfSymbol` never changes. But I'm not 
> sure if that's actually safe or how to tell D to allow a global 
> variable in pure code.

If you make global variables `immutable`, you can access them in 
`pure` functions.
`pure` functions are not really meant to access global mutable 
data.

> I often need to cast away  `scope` using a function 
> `castNonScope`.
> This feels like it needs a language intrinsic or at least a 
> standard
> library function.

I think you're not meant to cast away `scope`?? `scope` is meant 
to guarantee that a variable doesn't escape the given scope; 
casting it away breaks that guarantee, so why use it? If you're 
using it for memory allocation, be careful... it's not meant for 
that.


More information about the Digitalmars-d-announce mailing list