digitalmars.D.announce - Safer D is implemented!
- Walter Bright (12/12) Nov 27 2024 https://github.com/dlang/dmd/pull/17044
- Jonathan M Davis (6/19) Nov 28 2024 So, essentially, it makes functions with no explicit @safety attributes ...
- Walter Bright (1/1) Nov 28 2024 Right.
- f (10/11) Nov 28 2024 11 languages have coroutine support natively
- Richard (Rikki) Andrew Cattermole (5/21) Nov 28 2024 I'll be restarting on my language design work, including coroutines next...
- Sergey (5/10) Nov 28 2024 People mostly with C99 and C++(who even touch 20th standard,
- Duan Tihua (6/8) Nov 29 2024 For writing memory safe code, this is a more practical
- Andrej Mitrovic (5/9) Dec 29 2024 This is pretty cool!
- Andrej Mitrovic (26/28) Dec 29 2024 I think this is going to still cause issues with dependencies,
- Andrej Mitrovic (18/49) Dec 29 2024 So essentially this might even work fine if I used .di
https://github.com/dlang/dmd/pull/17044 It's enabled with -preview=safer It enables "safe by default". This is different from marking functions as safe, in that: 1. it does not mark the function as safe, the function mangling does not change 2. it enables all safe checks except it does not complain about calling system functions 3. it does not interfere with attribute inference In other words, it does not impose transitive safety. You can still call malloc() and printf() in it. Once it appears in the next release, I encourage people to add -preview=safer to their build process.
Nov 27 2024
On Thursday, November 28, 2024 12:08:29 AM MST Walter Bright via Digitalmars- d-announce wrote:https://github.com/dlang/dmd/pull/17044 It's enabled with -preview=safer It enables "safe by default". This is different from marking functions as safe, in that: 1. it does not mark the function as safe, the function mangling does not change 2. it enables all safe checks except it does not complain about calling system functions 3. it does not interfere with attribute inference In other words, it does not impose transitive safety. You can still call malloc() and printf() in it. Once it appears in the next release, I encourage people to add -preview=safer to their build process.So, essentially, it makes functions with no explicit safety attributes be somewhere between system and safe by disallowing language constructs which are considered system but not disallowing calling system functions. - Jonathan M Davis
Nov 28 2024
On Thursday, 28 November 2024 at 21:01:30 UTC, Walter Bright wrote:Right.11 languages have coroutine support natively Only 1 with full borrow semantics : rust. That according to chatgpt Please sir , the coroutine dips is still at 1st draft. While other dip will make lines fewer , their execution still from top down. The coroutine, is a game changer. That will make porting library from other languages straightforward.
Nov 28 2024
On 29/11/2024 10:30 AM, f wrote:On Thursday, 28 November 2024 at 21:01:30 UTC, Walter Bright wrote:I'll be restarting on my language design work, including coroutines next year. I'm taking a few months where I work on my own stuff. I have not forgotten any of the design work :)Right.11 languages have coroutine support natively Only 1 with full borrow semantics : rust. That according to chatgpt Please sir , the coroutine dips is still at 1st draft. While other dip will make lines fewer , their execution still from top down. The coroutine, is a game changer. That will make portingĀ library from other languages straightforward.
Nov 28 2024
On Thursday, 28 November 2024 at 21:30:33 UTC, f wrote:On Thursday, 28 November 2024 at 21:01:30 UTC, Walter Bright wrote:People mostly with C99 and C++(who even touch 20th standard, right?) experience will answer: we have core.thread and std.concurrency for years.. this is enough, what else do you want? :PRight.The coroutine, is a game changer. That will make porting library from other languages straightforward.
Nov 28 2024
On Thursday, 28 November 2024 at 07:08:29 UTC, Walter Bright wrote:https://github.com/dlang/dmd/pull/17044 It's enabled with -preview=saferFor writing memory safe code, this is a more practical engineering approach. Fortunately, this compilation option will reduce the number of times safe annotation is used and the code will be relatively cleaner.
Nov 29 2024
On Thursday, 28 November 2024 at 07:08:29 UTC, Walter Bright wrote:https://github.com/dlang/dmd/pull/17044 It's enabled with -preview=saferThis is pretty cool! But I've noticed it shows errors for ImportC code:lib\gen-blend2d-windows\blend2d.c(207,45): Error: cast from `int` to `void*` not allowed in safe codeIs there a bug report for it?
Dec 29 2024
On Thursday, 28 November 2024 at 07:08:29 UTC, Walter Bright wrote:https://github.com/dlang/dmd/pull/17044 It's enabled with -preview=saferI think this is going to still cause issues with dependencies, which might just be a dub problem but I'm not sure. For example I've tried to add `dflags `-preview=safer` to my dub.sdl and now I get errors from 3rd party libraries: ``` lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(326,24): Error: `name.ptr` cannot be used in ` safe` code, use `&name[0]` instead lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(342,33): Error: ` safe` function `loadGLFW` cannot access `__gshared` data `glfwInit` lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(342,20): Error: cast from `extern (C) int function() nothrow nogc*` to `void**` not allowed in safe code lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(343,33): Error: ` safe` function `loadGLFW` cannot access `__gshared` data `glfwTerminate` lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(343,20): Error: cast from `extern (C) void function() nothrow nogc*` to `void**` not allowed in safe code lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(344,33): Error: ` safe` function `loadGLFW` cannot access `__gshared` data `glfwGetVersion` ``` Still it's a great step forward, thanks for your work~
Dec 29 2024
On Sunday, 29 December 2024 at 12:22:42 UTC, Andrej Mitrovic wrote:On Thursday, 28 November 2024 at 07:08:29 UTC, Walter Bright wrote:So essentially this might even work fine if I used .di dependencies instead of .d, as that would hide the implementation code from the compiler so it couldn't do any analysis (never mind that nobody uses .di). But with templates it wouldn't be a workable solution anyway. I don't see how anyone is going to try and use -preview=safer *unless* they are able to use other libraries which are ready for this switch. But most libraries will not be ready for it. Therefore people who use libraries will not be able to enable this switch. Therefore this is a catch-22 problem. I don't know if it's possible to limit certain switches to particular packages, but I would prefer if I could enable the `-preview=safer` switch *only* for code within `./src`. In other words code I directly have control over. Is that possible with dub..?https://github.com/dlang/dmd/pull/17044 It's enabled with -preview=saferI think this is going to still cause issues with dependencies, which might just be a dub problem but I'm not sure. For example I've tried to add `dflags `-preview=safer` to my dub.sdl and now I get errors from 3rd party libraries: ``` lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(326,24): Error: `name.ptr` cannot be used in ` safe` code, use `&name[0]` instead lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(342,33): Error: ` safe` function `loadGLFW` cannot access `__gshared` data `glfwInit` lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(342,20): Error: cast from `extern (C) int function() nothrow nogc*` to `void**` not allowed in safe code lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(343,33): Error: ` safe` function `loadGLFW` cannot access `__gshared` data `glfwTerminate` lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(343,20): Error: cast from `extern (C) void function() nothrow nogc*` to `void**` not allowed in safe code lib\bindbc-glfw\source\bindbc\glfw\binddynamic.d(344,33): Error: ` safe` function `loadGLFW` cannot access `__gshared` data `glfwGetVersion` ``` Still it's a great step forward, thanks for your work~
Dec 29 2024