Re: Status of @nogc with the runtime

2018-02-17 Thread Peter Campbell via Digitalmars-d
On Saturday, 17 February 2018 at 23:43:07 UTC, Adam D. Ruppe wrote: On Saturday, 17 February 2018 at 18:03:44 UTC, Peter Campbell wrote: Andrei mentioned at his DConf presentations is that the runtime itself will be modified to not rely on the GC, allowing for you to continue using features suc

Re: Status of @nogc with the runtime

2018-02-17 Thread Adam D. Ruppe via Digitalmars-d
On Saturday, 17 February 2018 at 18:03:44 UTC, Peter Campbell wrote: Andrei mentioned at his DConf presentations is that the runtime itself will be modified to not rely on the GC, allowing for you to continue using features such as associative arrays and array concatenation, but without requiri

Re: Status of @nogc with the runtime

2018-02-17 Thread Peter Campbell via Digitalmars-d
On Saturday, 17 February 2018 at 19:32:50 UTC, bachmeier wrote: On Saturday, 17 February 2018 at 18:03:44 UTC, Peter Campbell wrote: My understanding from the vision documents and what Andrei mentioned at his DConf presentations is that the runtime itself will be modified to not rely on the G

Re: Status of @nogc with the runtime

2018-02-17 Thread bachmeier via Digitalmars-d
On Saturday, 17 February 2018 at 18:03:44 UTC, Peter Campbell wrote: My understanding from the vision documents and what Andrei mentioned at his DConf presentations is that the runtime itself will be modified to not rely on the GC, allowing for you to continue using features such as associati

Re: Status of @nogc with the runtime

2018-02-17 Thread Peter Campbell via Digitalmars-d
ing :) I'm writing a library for @nogc D programming, tanya. It has different aims than -betterC: I use the full set of D features, just except features that require GC. It isn't complete, I'm using it only in personal projects and it is also a big learn project for me, so don'

Re: Status of @nogc with the runtime

2018-02-17 Thread Seb via Digitalmars-d
On Saturday, 17 February 2018 at 12:18:28 UTC, Peter Campbell wrote: Hi everyone, it's been almost a year since I used D but I was wanted to get back into it. I was checking the 2017 vision pages and was wondering why there hasn't been a 2018H1 vision page but also what the current status of be

Re: Status of @nogc with the runtime

2018-02-17 Thread Eugene Wissner via Digitalmars-d
status of being able to use D without a garbage collector is? It was noted in the H1 and H2 pages for 2017 but looking through the compiler changelog doesn't indicate that we're there yet? https://wiki.dlang.org/Vision/2017H2 Thanks. Let me do a bit advertising :) I'm writ

Re: Status of @nogc with the runtime

2018-02-17 Thread Mike Franklin via Digitalmars-d
On Saturday, 17 February 2018 at 12:18:28 UTC, Peter Campbell wrote: I was checking the 2017 vision pages and was wondering why there hasn't been a 2018H1 vision page but also what the current status of being able to use D without a garbage collector is? There are a number of ways to use D wi

Status of @nogc with the runtime

2018-02-17 Thread Peter Campbell via Digitalmars-d
Hi everyone, it's been almost a year since I used D but I was wanted to get back into it. I was checking the 2017 vision pages and was wondering why there hasn't been a 2018H1 vision page but also what the current status of being able to use D without a garbage collector is? It was noted in t

Re: Error: @nogc function 'test.func2' cannot call non-@nogc delegate 'msg'

2017-12-10 Thread Shachar Shemesh via Digitalmars-d
Submitted https://issues.dlang.org/show_bug.cgi?id=18058 On 10/12/17 14:07, Shachar Shemesh wrote: On 10/12/17 14:00, Shachar Shemesh wrote: On 10/12/17 13:44, Jonathan M Davis wrote: it sounds like the delegate that's being generated isn't @nogc, so it can't be called with

Re: Error: @nogc function 'test.func2' cannot call non-@nogc delegate 'msg'

2017-12-10 Thread A Guy With a Question via Digitalmars-d
On Sunday, 10 December 2017 at 11:44:20 UTC, Jonathan M Davis wrote: On Sunday, December 10, 2017 12:54:00 Shachar Shemesh via Digitalmars-d wrote: void func1(scope lazy string msg) @nogc { } void func2(scope lazy string msg) @nogc { func1(msg); } What? Why is msg GC allocating

Re: Error: @nogc function 'test.func2' cannot call non-@nogc delegate 'msg'

2017-12-10 Thread Shachar Shemesh via Digitalmars-d
On 10/12/17 14:00, Shachar Shemesh wrote: On 10/12/17 13:44, Jonathan M Davis wrote: it sounds like the delegate that's being generated isn't @nogc, so it can't be called within the function, which would be a completely different issue from allocating a closure. Here'

Re: Error: @nogc function 'test.func2' cannot call non-@nogc delegate 'msg'

2017-12-10 Thread Shachar Shemesh via Digitalmars-d
On 10/12/17 13:44, Jonathan M Davis wrote: it sounds like the delegate that's being generated isn't @nogc, so it can't be called within the function, which would be a completely different issue from allocating a closure. Here's the thing, though. There is no reason fo

Re: Error: @nogc function 'test.func2' cannot call non-@nogc delegate 'msg'

2017-12-10 Thread Jonathan M Davis via Digitalmars-d
On Sunday, December 10, 2017 12:54:00 Shachar Shemesh via Digitalmars-d wrote: > void func1(scope lazy string msg) @nogc { > } > > void func2(scope lazy string msg) @nogc { > func1(msg); > } > > What? Why is msg GC allocating, especially since I scoped the lazy? Why

Error: @nogc function 'test.func2' cannot call non-@nogc delegate 'msg'

2017-12-10 Thread Shachar Shemesh via Digitalmars-d
void func1(scope lazy string msg) @nogc { } void func2(scope lazy string msg) @nogc { func1(msg); } What? Why is msg GC allocating, especially since I scoped the lazy? Why is msg even evaluated? Something seems off here. Thanks, Shachar

Re: Specifying @nogc on structs seems to have no effect

2017-09-20 Thread B4s1L3 via Digitalmars-d
ingle file package). Wow! Yeah that seems like almost exactly what I want. Sorry what is iz? Thank you! -Craig It's a D user library: https://github.com/BBasile/iz. I forgot to say but the @NoGc data annotation relies on construct(). Neither `new` not `std.experimental.allocator.ma

Re: Specifying @nogc on structs seems to have no effect

2017-09-20 Thread Craig Black via Digitalmars-d
On Wednesday, 20 September 2017 at 02:43:44 UTC, B4s1L3 wrote: It's another way of doing things. It's less strict than checking all the functions. note: the script can be run directly by passing the file to DUB (single file package). Wow! Yeah that seems like almost exactly what I want. So

Re: Specifying @nogc on structs seems to have no effect

2017-09-20 Thread Craig Black via Digitalmars-d
on-GC heap using malloc and free and emplace, but I find it troubling that you still need to tell the GC to scan your allocation. What I would like is, for example, to be able to write a @nogc templated struct that guarantees that none of its members require GC scanning. Thus: @nogc struct Ar

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread B4s1L3 via Digitalmars-d
nd it troubling that you still need to tell the GC to scan your allocation. What I would like is, for example, to be able to write a @nogc templated struct that guarantees that none of its members require GC scanning. Thus: @nogc struct Array(T) { ... } class GarbageCollectedClass { } void

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread Craig Black via Digitalmars-d
On Tuesday, 19 September 2017 at 20:57:17 UTC, Neia Neutuladh wrote: On Tuesday, 19 September 2017 at 15:11:31 UTC, Craig Black wrote: [...] You want to ensure that it can never refer to GC memory. The type system does not contain that information. It doesn't say whether an object was alloca

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread Neia Neutuladh via Digitalmars-d
e binary's static data segment... So @nogc can't help you. You could, however, replace the GC implementation with one that throws an AssertError whenever the GC runs a collection, allocates memory, etc. Or you could just add @nogc to your main function. If you want to forbid all refere

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread ag0aep6g via Digitalmars-d
On 09/19/2017 08:06 PM, Craig Black wrote: This wouldn't be allowed for classes or class references, since they are always pointing to GC data That's not true. You can put class objects into other places than the GC heap.

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread Steven Schveighoffer via Digitalmars-d
On 9/19/17 2:06 PM, Craig Black wrote: Thank you for the clarification. I understand mow that @nogc is only for functions and not for data types.  Thinking out loud, it would seem beneficial if there was a way to mark a pointer or data structure as not pointing to the GC heap. A guarantee to

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread Craig Black via Digitalmars-d
ample, to be able to write a @nogc templated struct that guarantees that none of its members require GC scanning.  Thus: @nogc struct Array(T) {    ... } class GarbageCollectedClass { } void main() {    Array!int intArray; // fine } @nogc is a function attribute. It has no effect on types e

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread Steven Schveighoffer via Digitalmars-d
he GC in any way. I realize that you can allocate on the non-GC heap using malloc and free and emplace, but I find it troubling that you still need to tell the GC to scan your allocation. What I would like is, for example, to be able to write a @nogc templated struct that guarantees that none o

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread Craig Black via Digitalmars-d
On Tuesday, 19 September 2017 at 14:34:10 UTC, Mike Parker wrote: On Tuesday, 19 September 2017 at 14:22:21 UTC, Craig Black wrote: Thank you for your response. The @nogc attribute is good, but in my opinion it is incomplete if all types still require scanning. The purpose of not employing

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread Mike Parker via Digitalmars-d
On Tuesday, 19 September 2017 at 14:22:21 UTC, Craig Black wrote: Thank you for your response. The @nogc attribute is good, but in my opinion it is incomplete if all types still require scanning. The purpose of not employing GC in certain sections of code is performance, and we are

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread Craig Black via Digitalmars-d
u can allocate on the non-GC heap using malloc and free and emplace, but I find it troubling that you still need to tell the GC to scan your allocation. What I would like is, for example, to be able to write a @nogc templated struct that guarantees that none of its members require GC scanning.

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread John Colvin via Digitalmars-d
nd it troubling that you still need to tell the GC to scan your allocation. What I would like is, for example, to be able to write a @nogc templated struct that guarantees that none of its members require GC scanning. Thus: @nogc struct Array(T) { ... } class GarbageCollectedClass { } void

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread Jonathan M Davis via Digitalmars-d
ng malloc > and free and emplace, but I find it troubling that you still need > to tell the GC to scan your allocation. What I would like is, for > example, to be able to write a @nogc templated struct that > guarantees that none of its members require GC scanning. Thus: > >

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread ag0aep6g via Digitalmars-d
On 09/19/2017 03:46 PM, Craig Black wrote: struct MyStruct { @nogc: public:   Foo foo; // This does not produce an error, but it still requires a GC scan @nogc is about GC allocations. `Foo foo;` doesn't cause a GC allocation. @nogc doesn't control what memory is scanned by the GC.

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread Mike Parker via Digitalmars-d
On Tuesday, 19 September 2017 at 13:46:20 UTC, Craig Black wrote: Thanks, I didn't know you could to that but it still doesn't give me the behavior that I want: class Foo { } struct MyStruct { @nogc: public: Foo foo; // This does not produce an error, but it still requires

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread drug via Digitalmars-d
19.09.2017 16:46, Craig Black пишет: class Foo { } struct MyStruct { @nogc: public:   Foo foo; // This does not produce an error, but it still requires a GC scan   void Bar()   {     foo = new Foo; // This produces an error   } } it produces an error for me https://run.dlang.io/is

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread drug via Digitalmars-d
19.09.2017 16:49, drug пишет: 19.09.2017 16:48, drug пишет: 19.09.2017 16:46, Craig Black пишет: class Foo { } struct MyStruct { @nogc: public:    Foo foo; // This does not produce an error, but it still requires a GC scan    void Bar()    { foo = new Foo; // This produces an error

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread Craig Black via Digitalmars-d
n the non-GC heap using malloc and free and emplace, but I find it troubling that you still need to tell the GC to scan your allocation. What I would like is, for example, to be able to write a @nogc templated struct that guarantees that none of its members require GC scanning. Thus: @nogc s

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread drug via Digitalmars-d
19.09.2017 16:48, drug пишет: 19.09.2017 16:46, Craig Black пишет: class Foo { } struct MyStruct { @nogc: public:    Foo foo; // This does not produce an error, but it still requires a GC scan    void Bar()    { foo = new Foo; // This produces an error    } } it produces an error for

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread Eugene Wissner via Digitalmars-d
nd it troubling that you still need to tell the GC to scan your allocation. What I would like is, for example, to be able to write a @nogc templated struct that guarantees that none of its members require GC scanning. Thus: @nogc struct Array(T) { ... } class GarbageCollectedClass { } void

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread Andrea Fontana via Digitalmars-d
On Tuesday, 19 September 2017 at 13:13:48 UTC, Craig Black wrote: @nogc struct Array(T) { ... } class GarbageCollectedClass { } void main() { Array!int intArray; // fine Array!GarbageCollectedClass classArray; // Error: struct Array is @nogc } If you want to enforce that behaviour I

Re: Specifying @nogc on structs seems to have no effect

2017-09-19 Thread Craig Black via Digitalmars-d
nd it troubling that you still need to tell the GC to scan your allocation. What I would like is, for example, to be able to write a @nogc templated struct that guarantees that none of its members require GC scanning. Thus: @nogc struct Array(T) { ... } class GarbageCollectedClass { } void

Specifying @nogc on structs seems to have no effect

2017-09-19 Thread Craig Black via Digitalmars-d
What I would like is, for example, to be able to write a @nogc templated struct that guarantees that none of its members require GC scanning. Thus: @nogc struct Array(T) { ... } class GarbageCollectedClass { } void main() { Array!int intArray; // fine }

Re: all OS functions should be "nothrow @trusted @nogc"

2017-08-02 Thread Moritz Maxeiner via Digitalmars-d
On Wednesday, 2 August 2017 at 16:32:44 UTC, Andrei Alexandrescu wrote: import std.algorithm; // I probably wouldn't even define this but use the body as is auto strnlen_safe(in char[] str) { return countUntil(cast(ubyte[]) str, '\0'); } Oh that cast it irks me so. -Steve return str

Re: all OS functions should be "nothrow @trusted @nogc"

2017-08-02 Thread Andrei Alexandrescu via Digitalmars-d
import std.algorithm; // I probably wouldn't even define this but use the body as is auto strnlen_safe(in char[] str) { return countUntil(cast(ubyte[]) str, '\0'); } Oh that cast it irks me so. -Steve return str.representation.countUntil('\0'); Andrei

Re: all OS functions should be "nothrow @trusted @nogc"

2017-08-01 Thread Moritz Maxeiner via Digitalmars-d
On Tuesday, 1 August 2017 at 22:52:26 UTC, H. S. Teoh wrote: On Tue, Aug 01, 2017 at 06:46:17PM -0400, Steven Schveighoffer via Digitalmars-d wrote: On 8/1/17 6:17 PM, Moritz Maxeiner wrote: [...] > import std.algorithm; > // I probably wouldn't even define this but use the body as > is > au

Re: all OS functions should be "nothrow @trusted @nogc"

2017-08-01 Thread H. S. Teoh via Digitalmars-d
On Tue, Aug 01, 2017 at 06:46:17PM -0400, Steven Schveighoffer via Digitalmars-d wrote: > On 8/1/17 6:17 PM, Moritz Maxeiner wrote: [...] > > import std.algorithm; > > // I probably wouldn't even define this but use the body as is > > auto strnlen_safe(in char[] str) > > { > > return countUnt

Re: all OS functions should be "nothrow @trusted @nogc"

2017-08-01 Thread Steven Schveighoffer via Digitalmars-d
On 8/1/17 6:17 PM, Moritz Maxeiner wrote: On Tuesday, 1 August 2017 at 21:59:46 UTC, Steven Schveighoffer wrote: On 8/1/17 5:54 PM, Moritz Maxeiner wrote: On Tuesday, 1 August 2017 at 20:39:35 UTC, Marco Leise wrote: Am Tue, 1 Aug 2017 10:50:59 -0700 schrieb "H. S. Teoh via Digitalmars-d" : O

Re: all OS functions should be "nothrow @trusted @nogc"

2017-08-01 Thread Moritz Maxeiner via Digitalmars-d
On Tuesday, 1 August 2017 at 21:59:46 UTC, Steven Schveighoffer wrote: On 8/1/17 5:54 PM, Moritz Maxeiner wrote: On Tuesday, 1 August 2017 at 20:39:35 UTC, Marco Leise wrote: Am Tue, 1 Aug 2017 10:50:59 -0700 schrieb "H. S. Teoh via Digitalmars-d" : On Tue, Aug 01, 2017 at 05:12:38PM +, w0

Re: all OS functions should be "nothrow @trusted @nogc"

2017-08-01 Thread Steven Schveighoffer via Digitalmars-d
On 8/1/17 5:54 PM, Moritz Maxeiner wrote: On Tuesday, 1 August 2017 at 20:39:35 UTC, Marco Leise wrote: Am Tue, 1 Aug 2017 10:50:59 -0700 schrieb "H. S. Teoh via Digitalmars-d" : On Tue, Aug 01, 2017 at 05:12:38PM +, w0rp via Digitalmars-d wrote: > Direct OS function calls should probably

Re: all OS functions should be "nothrow @trusted @nogc"

2017-08-01 Thread Moritz Maxeiner via Digitalmars-d
On Tuesday, 1 August 2017 at 20:39:35 UTC, Marco Leise wrote: Am Tue, 1 Aug 2017 10:50:59 -0700 schrieb "H. S. Teoh via Digitalmars-d" : On Tue, Aug 01, 2017 at 05:12:38PM +, w0rp via Digitalmars-d wrote: > Direct OS function calls should probably all be treated as > unsafe, except for rar

Re: all OS functions should be "nothrow @trusted @nogc"

2017-08-01 Thread H. S. Teoh via Digitalmars-d
On Tue, Aug 01, 2017 at 10:39:35PM +0200, Marco Leise via Digitalmars-d wrote: > Am Tue, 1 Aug 2017 10:50:59 -0700 > schrieb "H. S. Teoh via Digitalmars-d" > : > > > On Tue, Aug 01, 2017 at 05:12:38PM +, w0rp via Digitalmars-d wrote: > > > Direct OS function calls should probably all be treate

Re: all OS functions should be "nothrow @trusted @nogc"

2017-08-01 Thread Marco Leise via Digitalmars-d
Am Tue, 1 Aug 2017 10:50:59 -0700 schrieb "H. S. Teoh via Digitalmars-d" : > On Tue, Aug 01, 2017 at 05:12:38PM +, w0rp via Digitalmars-d wrote: > > Direct OS function calls should probably all be treated as unsafe, > > except for rare cases where the behaviour is very well defined in > > stan

Re: all OS functions should be "nothrow @trusted @nogc"

2017-08-01 Thread H. S. Teoh via Digitalmars-d
On Tue, Aug 01, 2017 at 05:12:38PM +, w0rp via Digitalmars-d wrote: > Direct OS function calls should probably all be treated as unsafe, > except for rare cases where the behaviour is very well defined in > standards and in actual implementations to be safe. The way to get > safe functions for

Re: all OS functions should be "nothrow @trusted @nogc"

2017-08-01 Thread w0rp via Digitalmars-d
Direct OS function calls should probably all be treated as unsafe, except for rare cases where the behaviour is very well defined in standards and in actual implementations to be safe. The way to get safe functions for OS functionality is to write wrapper functions in D which prohibit unsafe ca

Re: all OS functions should be "nothrow @trusted @nogc"

2017-08-01 Thread Kagamin via Digitalmars-d
On Monday, 31 July 2017 at 13:56:48 UTC, Shachar Shemesh wrote: One of the things that really bother me with the D community is the "100% or nothing" approach. In the worst case when a function becomes unsafe, only @safe attribute will be removed from it, which will be a breaking change, but

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-31 Thread Vladimir Panteleev via Digitalmars-d
On Monday, 31 July 2017 at 14:51:22 UTC, Timon Gehr wrote: On 31.07.2017 16:15, Shachar Shemesh wrote: That's fine, but since, according to the logic presented here, no OS function can ever be @safe, This is actually not true. Vladimir was just pointing out a complication of which to be aware

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-31 Thread Timon Gehr via Digitalmars-d
On 31.07.2017 16:15, Shachar Shemesh wrote: Why do you think @trusted exists? That's fine, but since, according to the logic presented here, no OS function can ever be @safe, This is actually not true. Vladimir was just pointing out a complication of which to be aware. Are you arguing agai

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-31 Thread Shachar Shemesh via Digitalmars-d
On 31/07/17 17:08, Timon Gehr wrote: On 31.07.2017 15:56, Shachar Shemesh wrote: One of the things that really bother me with the D community is the "100% or nothing" approach. ... Personally, I'm more bothered by this kind of lazy argument that sounds good but has no substance. System p

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-31 Thread Timon Gehr via Digitalmars-d
On 31.07.2017 15:56, Shachar Shemesh wrote: One of the things that really bother me with the D community is the "100% or nothing" approach. ... Personally, I'm more bothered by this kind of lazy argument that sounds good but has no substance. System programming is, by definition, an exerc

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-31 Thread Shachar Shemesh via Digitalmars-d
On 31/07/17 16:33, Vladimir Panteleev wrote: On Wednesday, 26 July 2017 at 17:48:21 UTC, Walter Bright wrote: On 7/26/2017 6:29 AM, Kagamin wrote: Should we still try to mark them safe at all? Marking ones that are safe with @safe is fine. OS APIs pretty much never change. Sometimes operat

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-31 Thread Vladimir Panteleev via Digitalmars-d
On Wednesday, 26 July 2017 at 17:48:21 UTC, Walter Bright wrote: On 7/26/2017 6:29 AM, Kagamin wrote: Should we still try to mark them safe at all? Marking ones that are safe with @safe is fine. OS APIs pretty much never change. Sometimes operating systems add new flags to their API which

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-29 Thread Kagamin via Digitalmars-d
There's a less questionable problem with it. Hint: FILE struct is transparent, look inside it, lots of interesting stuff there.

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-28 Thread Grander via Digitalmars-d
On Friday, 28 July 2017 at 12:40:06 UTC, Kagamin wrote: On Wednesday, 26 July 2017 at 17:48:21 UTC, Walter Bright wrote: On 7/26/2017 6:29 AM, Kagamin wrote: Should we still try to mark them safe at all? Marking ones that are safe with @safe is fine. OS APIs pretty much never change. New t

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-28 Thread Kagamin via Digitalmars-d
On Wednesday, 26 July 2017 at 17:48:21 UTC, Walter Bright wrote: On 7/26/2017 6:29 AM, Kagamin wrote: Should we still try to mark them safe at all? Marking ones that are safe with @safe is fine. OS APIs pretty much never change. New technologies and new features get introduced over time: 64

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-27 Thread Jacob Carlborg via Digitalmars-d
On 2017-07-27 13:46, Steven Schveighoffer wrote: So the result is that it will segfault. I don't see a problem with this. It's what I would have expected. The problem is that behavior might change depending on which compiler is used because the code is not valid according to the specification

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-27 Thread Andrei Alexandrescu via Digitalmars-d
On 07/25/2017 10:54 PM, Walter Bright wrote: On 7/25/2017 8:26 AM, Andrei Alexandrescu wrote: A suite of safe wrappers on OS primitives might be useful. The idea of fixing the operating system interface(s) has come up now and then. I've tried to discourage that on the following grounds: *

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-27 Thread Moritz Maxeiner via Digitalmars-d
On Thursday, 27 July 2017 at 14:45:03 UTC, Steven Schveighoffer wrote: On 7/27/17 10:20 AM, Moritz Maxeiner wrote: On Thursday, 27 July 2017 at 13:56:00 UTC, Steven Schveighoffer wrote: I'm fine with saying libraries or platforms that do not segfault when accessing zero page are incompatible

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-27 Thread Patrick Schluter via Digitalmars-d
On Thursday, 27 July 2017 at 11:46:24 UTC, Steven Schveighoffer wrote: On 7/27/17 2:48 AM, Jacob Carlborg wrote: And then the compiler runs the "Dead Code Elimination" pass and we're left with: void contains_null_check(int* p) { *p = 4; } So the result is that it will segfault. I don't

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-27 Thread Steven Schveighoffer via Digitalmars-d
On 7/27/17 10:20 AM, Moritz Maxeiner wrote: On Thursday, 27 July 2017 at 13:56:00 UTC, Steven Schveighoffer wrote: On 7/27/17 9:24 AM, Moritz Maxeiner wrote: On Wednesday, 26 July 2017 at 01:09:50 UTC, Steven Schveighoffer wrote: I think we can correctly assume no fclose implementations exist t

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-27 Thread Moritz Maxeiner via Digitalmars-d
On Thursday, 27 July 2017 at 13:56:00 UTC, Steven Schveighoffer wrote: On 7/27/17 9:24 AM, Moritz Maxeiner wrote: On Wednesday, 26 July 2017 at 01:09:50 UTC, Steven Schveighoffer wrote: I think we can correctly assume no fclose implementations exist that do anything but access data pointed at b

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-27 Thread Moritz Maxeiner via Digitalmars-d
On Thursday, 27 July 2017 at 13:45:21 UTC, ag0aep6g wrote: On 07/27/2017 03:24 PM, Moritz Maxeiner wrote: --- null.d --- version (linux): import core.stdc.stdio : FILE; import core.sys.linux.sys.mman; extern (C) @safe int fgetc(FILE* stream); void mmapNull() { void* mmapNull = mmap(null,

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-27 Thread Steven Schveighoffer via Digitalmars-d
On 7/27/17 9:24 AM, Moritz Maxeiner wrote: On Wednesday, 26 July 2017 at 01:09:50 UTC, Steven Schveighoffer wrote: I think we can correctly assume no fclose implementations exist that do anything but access data pointed at by stream. Which means a segfault on every platform we support. On pla

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-27 Thread ag0aep6g via Digitalmars-d
On 07/27/2017 03:24 PM, Moritz Maxeiner wrote: --- null.d --- version (linux): import core.stdc.stdio : FILE; import core.sys.linux.sys.mman; extern (C) @safe int fgetc(FILE* stream); void mmapNull() { void* mmapNull = mmap(null, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-27 Thread Moritz Maxeiner via Digitalmars-d
On Wednesday, 26 July 2017 at 01:09:50 UTC, Steven Schveighoffer wrote: On 7/25/17 8:45 PM, Timon Gehr wrote: On 26.07.2017 02:35, Steven Schveighoffer wrote: On 7/25/17 5:23 PM, Moritz Maxeiner wrote: On Tuesday, 25 July 2017 at 20:16:41 UTC, Steven Schveighoffer wrote: The behavior is defin

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-27 Thread Andrei Alexandrescu via Digitalmars-d
On 07/27/2017 07:27 AM, Timon Gehr wrote: On 27.07.2017 02:11, Steven Schveighoffer wrote: On 7/26/17 7:56 PM, Andrei Alexandrescu wrote: On 07/26/2017 06:16 PM, Steven Schveighoffer wrote: So I guess I should restate that we can assume no implementations exist that intentionally cause UB when

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-27 Thread Steven Schveighoffer via Digitalmars-d
On 7/27/17 7:27 AM, Timon Gehr wrote: On 27.07.2017 02:11, Steven Schveighoffer wrote: On 7/26/17 7:56 PM, Andrei Alexandrescu wrote: On 07/26/2017 06:16 PM, Steven Schveighoffer wrote: So I guess I should restate that we can assume no implementations exist that intentionally cause UB when str

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-27 Thread Steven Schveighoffer via Digitalmars-d
On 7/27/17 2:48 AM, Jacob Carlborg wrote: And then the compiler runs the "Dead Code Elimination" pass and we're left with: void contains_null_check(int* p) { *p = 4; } So the result is that it will segfault. I don't see a problem with this. It's what I would have expected. -Steve

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-27 Thread Timon Gehr via Digitalmars-d
On 27.07.2017 02:11, Steven Schveighoffer wrote: On 7/26/17 7:56 PM, Andrei Alexandrescu wrote: On 07/26/2017 06:16 PM, Steven Schveighoffer wrote: So I guess I should restate that we can assume no implementations exist that intentionally cause UB when stream is NULL (as in Timon's example). E

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Jacob Carlborg via Digitalmars-d
On 2017-07-27 03:14, Steven Schveighoffer wrote: I can't see how compilers can take advantage of this one. However, we can take advantage that this UB is almost universally implemented as a hardware segfault that ends the process. Unfortunately it's not that easy with optimizing compilers for

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Steven Schveighoffer via Digitalmars-d
On 7/26/17 8:09 PM, Timon Gehr wrote: On 27.07.2017 01:56, Andrei Alexandrescu wrote: On 07/26/2017 06:16 PM, Steven Schveighoffer wrote: So I guess I should restate that we can assume no implementations exist that intentionally cause UB when stream is NULL (as in Timon's example). My argume

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Steven Schveighoffer via Digitalmars-d
On 7/26/17 7:56 PM, Andrei Alexandrescu wrote: On 07/26/2017 06:16 PM, Steven Schveighoffer wrote: So I guess I should restate that we can assume no implementations exist that intentionally cause UB when stream is NULL (as in Timon's example). Either they check for null, and handle gracefully,

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Timon Gehr via Digitalmars-d
On 27.07.2017 01:56, Andrei Alexandrescu wrote: On 07/26/2017 06:16 PM, Steven Schveighoffer wrote: So I guess I should restate that we can assume no implementations exist that intentionally cause UB when stream is NULL (as in Timon's example). My argument was not that we need to fear impleme

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Andrei Alexandrescu via Digitalmars-d
On 07/26/2017 06:16 PM, Steven Schveighoffer wrote: So I guess I should restate that we can assume no implementations exist that intentionally cause UB when stream is NULL (as in Timon's example). Either they check for null, and handle gracefully, or don't check and segfault. No need to worry

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Steven Schveighoffer via Digitalmars-d
On 7/26/17 12:08 PM, Patrick Schluter wrote: On Wednesday, 26 July 2017 at 01:09:50 UTC, Steven Schveighoffer wrote: On 7/25/17 8:45 PM, Timon Gehr wrote: On 26.07.2017 02:35, Steven Schveighoffer wrote: On 7/25/17 5:23 PM, Moritz Maxeiner wrote: On Tuesday, 25 July 2017 at 20:16:41 UTC, Stev

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Walter Bright via Digitalmars-d
On 7/26/2017 6:29 AM, Kagamin wrote: Should we still try to mark them safe at all? Marking ones that are safe with @safe is fine. OS APIs pretty much never change.

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Walter Bright via Digitalmars-d
On 7/26/2017 3:14 AM, Timon Gehr wrote: On 26.07.2017 05:02, Walter Bright wrote: The implementation checks for fp being NULL and returns EOF if it is. The C mindset is that this check is a waste of precious processing resources and morally wrong, as only a fool would pass NULL anyway, and fo

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Patrick Schluter via Digitalmars-d
On Wednesday, 26 July 2017 at 03:16:44 UTC, Walter Bright wrote: On 7/25/2017 6:09 PM, Steven Schveighoffer wrote: Likewise, because D depends on hardware flagging of dereferencing null as a segfault, any platforms that *don't* have that for C also won't have it for D. And then @safe doesn't e

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Patrick Schluter via Digitalmars-d
On Wednesday, 26 July 2017 at 01:09:50 UTC, Steven Schveighoffer wrote: On 7/25/17 8:45 PM, Timon Gehr wrote: On 26.07.2017 02:35, Steven Schveighoffer wrote: On 7/25/17 5:23 PM, Moritz Maxeiner wrote: On Tuesday, 25 July 2017 at 20:16:41 UTC, Steven Schveighoffer wrote: The behavior is defin

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Kagamin via Digitalmars-d
On Wednesday, 26 July 2017 at 02:54:34 UTC, Walter Bright wrote: * Operating system APIs grow like weeds. We'd set ourselves an impossible task. It is worthwhile, however, to augment the APIs with the appropriate attributes like @nogc, scope, nothrow, @safe (for the ones that are)

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Kagamin via Digitalmars-d
On Tuesday, 25 July 2017 at 18:36:35 UTC, Moritz Maxeiner wrote: fgetc cannot be @trusted the same way fclose cannot be @trusted. If you pass either of them `null` - which constitutes a legal @safe context - the behaviour is undefined, which contradicts @trusted definition: exhibit any undefine

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Steven Schveighoffer via Digitalmars-d
On 7/26/17 7:55 AM, Timon Gehr wrote: On 26.07.2017 13:22, Steven Schveighoffer wrote: On 7/26/17 6:01 AM, Timon Gehr wrote: On 26.07.2017 03:09, Steven Schveighoffer wrote: ... In other words, I think we can assume for any C functions that are passed pointers that dereference those pointers,

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Timon Gehr via Digitalmars-d
On 26.07.2017 13:22, Steven Schveighoffer wrote: On 7/26/17 6:01 AM, Timon Gehr wrote: On 26.07.2017 03:09, Steven Schveighoffer wrote: ... In other words, I think we can assume for any C functions that are passed pointers that dereference those pointers, passing null is safely going to segfa

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Steven Schveighoffer via Digitalmars-d
On 7/26/17 6:01 AM, Timon Gehr wrote: On 26.07.2017 03:09, Steven Schveighoffer wrote: On 7/25/17 8:45 PM, Timon Gehr wrote: ... What Moritz is saying is that the following implementation of fclose is correct according to the C standard: int fclose(FILE *stream){ if(stream == NULL){

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Steven Schveighoffer via Digitalmars-d
On 7/26/17 3:05 AM, Shachar Shemesh wrote: On 25/07/17 18:26, Andrei Alexandrescu wrote: (btw void[] doesn't work) Can you expand on this point? Shachar Because anything casts to void[] implicitly. e.g.: void main() @safe { int *[] arr = new int*[5]; read(0, arr); // reading raw poi

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Timon Gehr via Digitalmars-d
On 26.07.2017 05:02, Walter Bright wrote: On 7/25/2017 5:56 PM, Andrei Alexandrescu wrote: I'd think that would be the case, but failed to find a fgetc implementation that mentions it's undefined for a null FILE*. Is there a link? Thx. -- Andrei The documentation for DMC++ fgetc() is: htt

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Timon Gehr via Digitalmars-d
On 26.07.2017 02:56, Andrei Alexandrescu wrote: What Moritz is saying is that the following implementation of fclose is correct according to the C standard: int fclose(FILE *stream){ if(stream == NULL){ return go_wild_and_corrupt_all_the_memory(); }else{ return act

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Timon Gehr via Digitalmars-d
On 26.07.2017 03:09, Steven Schveighoffer wrote: On 7/25/17 8:45 PM, Timon Gehr wrote: ... What Moritz is saying is that the following implementation of fclose is correct according to the C standard: int fclose(FILE *stream){ if(stream == NULL){ return go_wild_and_corrupt_all_th

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Moritz Maxeiner via Digitalmars-d
assed to pthread_create does not, logically, run in the pthread_create function. As such, I don't think this logic holds. Then the @nogc definition would need to be updated from: "or indirectly through functions it may call" to reflect this, because that can be interpreted both wa

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Moritz Maxeiner via Digitalmars-d
On Wednesday, 26 July 2017 at 00:35:13 UTC, Steven Schveighoffer wrote: On 7/25/17 5:23 PM, Moritz Maxeiner wrote: On Tuesday, 25 July 2017 at 20:16:41 UTC, Steven Schveighoffer wrote: The behavior is defined. It will crash with a segfault. In C land that behaviour is a platform (hardware/OS/

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-26 Thread Shachar Shemesh via Digitalmars-d
On 25/07/17 18:26, Andrei Alexandrescu wrote: (btw void[] doesn't work) Can you expand on this point? Shachar

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-25 Thread Shachar Shemesh via Digitalmars-d
s such, I don't think this logic holds. Then the @nogc definition would need to be updated from: "or indirectly through functions it may call" to reflect this, because that can be interpreted both ways. As for pthread_join, I have no idea what you meant by it. Please elaborate

Re: all OS functions should be "nothrow @trusted @nogc"

2017-07-25 Thread Walter Bright via Digitalmars-d
On 7/25/2017 6:09 PM, Steven Schveighoffer wrote: Likewise, because D depends on hardware flagging of dereferencing null as a segfault, any platforms that *don't* have that for C also won't have it for D. And then @safe doesn't even work in D code either. I spent 10 years programming on DOS wi

<    1   2   3   4   5   6   7   8   9   10   >