Re: Trusted Manifesto

2015-02-10 Thread via Digitalmars-d
On Tuesday, 10 February 2015 at 15:57:28 UTC, Zach the Mystic wrote: On Tuesday, 10 February 2015 at 15:49:24 UTC, Zach the Mystic wrote: As already pointed out in the other thread, there is a non-breaking variant of (3): 3a. Keep named @trusted functions, allow @system blocks inside them,

Re: Trusted Manifesto

2015-02-10 Thread Zach the Mystic via Digitalmars-d
On Tuesday, 10 February 2015 at 15:49:24 UTC, Zach the Mystic wrote: Wait a second... you're totally right. That is a cool solution. The only hiccup is that it might be hard to implement in the compiler because of flow tracking (i.e. the error comes before the @system block, forcing a recheck

Re: Trusted Manifesto

2015-02-10 Thread Zach the Mystic via Digitalmars-d
On Tuesday, 10 February 2015 at 16:04:05 UTC, Marc Schütz wrote: On Tuesday, 10 February 2015 at 15:57:28 UTC, Zach the Mystic wrote: On Tuesday, 10 February 2015 at 15:49:24 UTC, Zach the Mystic wrote: As already pointed out in the other thread, there is a non-breaking variant of (3): 3a.

Re: Trusted Manifesto

2015-02-10 Thread Kagamin via Digitalmars-d
On Tuesday, 10 February 2015 at 04:05:35 UTC, Andrei Alexandrescu wrote: On 2/9/15 8:03 PM, Zach the Mystic wrote: You could put the 'trusted' template right in object.d, to save people the awkward burden of importing it from std.conv all the time. But that would be a language change, of

Re: Trusted Manifesto

2015-02-10 Thread Walter Bright via Digitalmars-d
On 2/9/2015 11:27 PM, Dicebot wrote: As you may see in generated call it actually calls lambda function (_D4test4mainFNfZ9__lambda1FNeZv) instead of calling _D4test3fooFZv directly https://issues.dlang.org/show_bug.cgi?id=14164

Re: Trusted Manifesto

2015-02-10 Thread Walter Bright via Digitalmars-d
On 2/9/2015 9:04 PM, Steven Schveighoffer wrote: This is not an issue that should dictate convention, non-inlined code does not impact correctness, only performance. And once it is fixed in the compiler, the argument would be gone, and we would be left with a convention with no good reason.

Re: Trusted Manifesto

2015-02-10 Thread Zach the Mystic via Digitalmars-d
On Tuesday, 10 February 2015 at 15:47:14 UTC, Zach the Mystic wrote: On Tuesday, 10 February 2015 at 12:27:29 UTC, Marc Schütz wrote: On Tuesday, 10 February 2015 at 06:35:08 UTC, Zach the Mystic wrote: I never used the named @trusted function for its original purpose anyway. I dont' see it as

Re: Trusted Manifesto

2015-02-10 Thread Zach the Mystic via Digitalmars-d
On Tuesday, 10 February 2015 at 12:27:29 UTC, Marc Schütz wrote: On Tuesday, 10 February 2015 at 06:35:08 UTC, Zach the Mystic wrote: I never used the named @trusted function for its original purpose anyway. I dont' see it as a big sacrifice, but anyway, you have three choices: 1. Keep

Re: Trusted Manifesto

2015-02-10 Thread Steven Schveighoffer via Digitalmars-d
On 2/10/15 9:06 AM, Russel Winder via Digitalmars-d wrote: On Mon, 2015-02-09 at 13:12 -0500, Steven Schveighoffer via Digitalmars-d wrote: On 2/9/15 12:57 PM, Andrei Alexandrescu wrote: On 2/9/15 7:48 AM, Steven Schveighoffer wrote: auto result = (() @trusted = cast(immutable)a)(); I'm

Re: Trusted Manifesto

2015-02-10 Thread Zach the Mystic via Digitalmars-d
On Tuesday, 10 February 2015 at 15:49:24 UTC, Zach the Mystic wrote: As already pointed out in the other thread, there is a non-breaking variant of (3): 3a. Keep named @trusted functions, allow @system blocks inside them, but only treat those with @system blocks with the new semantics. But

Re: Trusted Manifesto

2015-02-10 Thread via Digitalmars-d
On Tuesday, 10 February 2015 at 06:35:08 UTC, Zach the Mystic wrote: I never used the named @trusted function for its original purpose anyway. I dont' see it as a big sacrifice, but anyway, you have three choices: 1. Keep *named* @trusted functions for their original purpose, continue to

Re: Trusted Manifesto

2015-02-10 Thread Russel Winder via Digitalmars-d
On Mon, 2015-02-09 at 13:12 -0500, Steven Schveighoffer via Digitalmars-d wrote: On 2/9/15 12:57 PM, Andrei Alexandrescu wrote: On 2/9/15 7:48 AM, Steven Schveighoffer wrote: auto result = (() @trusted = cast(immutable)a)(); I'm okay with this as with most of Steve's points. But

Re: Trusted Manifesto

2015-02-09 Thread Dicebot via Digitalmars-d
string toUpper(string s) @safe { char[] r = new char[s.length]; foreach (i, c; s) r[i] = toUpper(c); return cast(string)r; // == unsafe operation } Shouldn't that be `return assumeUnique(r)` instead? What about requiring to put in-code comment that mentions

Re: Trusted Manifesto

2015-02-09 Thread Zach the Mystic via Digitalmars-d
On Tuesday, 10 February 2015 at 05:18:26 UTC, Andrei Alexandrescu wrote: On 2/9/15 9:06 PM, Dicebot wrote: On Tuesday, 10 February 2015 at 04:05:35 UTC, Andrei Alexandrescu wrote: On 2/9/15 8:03 PM, Zach the Mystic wrote: You could put the 'trusted' template right in object.d, to save people

Re: Trusted Manifesto

2015-02-09 Thread H. S. Teoh via Digitalmars-d
On Mon, Feb 09, 2015 at 12:19:10AM -0800, Walter Bright via Digitalmars-d wrote: [...] Trusted Manifesto - [...] RULE 1: @trusted code accessible from @safe code must expose a safe interface to unsafe operations. @trusted must not be used to inject unsafety into surrounding

Re: Trusted Manifesto

2015-02-09 Thread Zach the Mystic via Digitalmars-d
On Tuesday, 10 February 2015 at 03:36:14 UTC, Walter Bright wrote: On 2/9/2015 6:21 PM, H. S. Teoh via Digitalmars-d wrote: What stops the following abuse of @trusted via trusted()? int* myFunc(void* p) @safe // -- I'm claiming to be @safe { // But actually I'm

Re: Trusted Manifesto

2015-02-09 Thread Andrei Alexandrescu via Digitalmars-d
On 2/9/15 6:21 PM, H. S. Teoh via Digitalmars-d wrote: I wonder if there's a way, in the current language, to make it illegal to call trusted() from a function explicitly marked @safe...? No, but that might be worthy future consideration. I think we now should move forward with this and see

Re: Trusted Manifesto

2015-02-09 Thread Zach the Mystic via Digitalmars-d
On Tuesday, 10 February 2015 at 04:05:35 UTC, Andrei Alexandrescu wrote: On 2/9/15 8:03 PM, Zach the Mystic wrote: You could put the 'trusted' template right in object.d, to save people the awkward burden of importing it from std.conv all the time. But that would be a language change, of

Re: Trusted Manifesto

2015-02-09 Thread Walter Bright via Digitalmars-d
On 2/9/2015 6:21 PM, H. S. Teoh via Digitalmars-d wrote: What stops the following abuse of @trusted via trusted()? int* myFunc(void* p) @safe // -- I'm claiming to be @safe { // But actually I'm not! Though I can convince the // compiler that I

Re: Trusted Manifesto

2015-02-09 Thread Andrei Alexandrescu via Digitalmars-d
On 2/9/15 8:03 PM, Zach the Mystic wrote: You could put the 'trusted' template right in object.d, to save people the awkward burden of importing it from std.conv all the time. But that would be a language change, of sorts. We won't define it. Instead we'll go with Steve's idea: () @trusted =

Re: Trusted Manifesto

2015-02-09 Thread Walter Bright via Digitalmars-d
On 2/9/2015 9:06 PM, Dicebot wrote: This was exactly how all those trustedFoo() nested functions have appeared - we wanted to localized unsafe operations with `() @trusted {}` but it wasn't properly inlined by DMD. DMD will inline trivial functions like that. In what case does it not?

Re: Trusted Manifesto

2015-02-09 Thread Steven Schveighoffer via Digitalmars-d
and criticisms of the participants in the references. It involves no language changes, but offers usage guidelines that we believe are workable. Tell us what you think! Trusted Manifesto - Memory safety in D has the usual definition

Re: Trusted Manifesto

2015-02-09 Thread Steven Schveighoffer via Digitalmars-d
On 2/9/15 1:18 PM, Andrei Alexandrescu wrote: On 2/9/15 10:12 AM, Steven Schveighoffer wrote: On 2/9/15 12:57 PM, Andrei Alexandrescu wrote: On 2/9/15 7:48 AM, Steven Schveighoffer wrote: auto result = (() @trusted = cast(immutable)a)(); I'm okay with this as with most of Steve's points.

Re: Trusted Manifesto

2015-02-09 Thread Wyatt via Digitalmars-d
On Monday, 9 February 2015 at 18:18:23 UTC, Andrei Alexandrescu wrote: On 2/9/15 10:12 AM, Steven Schveighoffer wrote: Merriam Webster says otherwise ;) http://www.merriam-webster.com/dictionary/generic Interesting, thanks. Also, M-W does not list genericity. -- Webster needs to get over

Trusted Manifesto

2015-02-09 Thread Walter Bright via Digitalmars-d
that we believe are workable. Tell us what you think! Trusted Manifesto - Memory safety in D has the usual definition: a memory-safe program never reads uninitialized memory and never reads or writes memory with a type

Re: Trusted Manifesto

2015-02-09 Thread Dicebot via Digitalmars-d
On Tuesday, 10 February 2015 at 07:02:23 UTC, Walter Bright wrote: On 2/9/2015 9:06 PM, Dicebot wrote: This was exactly how all those trustedFoo() nested functions have appeared - we wanted to localized unsafe operations with `() @trusted {}` but it wasn't properly inlined by DMD. DMD will

Re: Trusted Manifesto

2015-02-09 Thread Steven Schveighoffer via Digitalmars-d
On 2/9/15 12:57 PM, Andrei Alexandrescu wrote: On 2/9/15 7:48 AM, Steven Schveighoffer wrote: auto result = (() @trusted = cast(immutable)a)(); I'm okay with this as with most of Steve's points. But genericness is not a word :o). -- Andrei Merriam Webster says otherwise ;)

Re: Trusted Manifesto

2015-02-09 Thread Andrei Alexandrescu via Digitalmars-d
On 2/9/15 2:09 AM, Kagamin wrote: Also why safe code is allowed to create unsafe lambdas? Might be interesting to restrict that. -- Andrei

Re: Trusted Manifesto

2015-02-09 Thread Andrei Alexandrescu via Digitalmars-d
On 2/9/15 2:05 AM, Kagamin wrote: On Monday, 9 February 2015 at 08:19:24 UTC, Walter Bright wrote: while not allowing std.conv.trusted escapes in @safe function would be by convention. Can SafeD be enforced given that? At some point you have to define a trusted computing base. That includes

Re: Trusted Manifesto

2015-02-09 Thread Andrei Alexandrescu via Digitalmars-d
On 2/9/15 7:48 AM, Steven Schveighoffer wrote: auto result = (() @trusted = cast(immutable)a)(); I'm okay with this as with most of Steve's points. But genericness is not a word :o). -- Andrei

Re: Trusted Manifesto

2015-02-09 Thread Andrei Alexandrescu via Digitalmars-d
On 2/9/15 10:12 AM, Steven Schveighoffer wrote: On 2/9/15 12:57 PM, Andrei Alexandrescu wrote: On 2/9/15 7:48 AM, Steven Schveighoffer wrote: auto result = (() @trusted = cast(immutable)a)(); I'm okay with this as with most of Steve's points. But genericness is not a word :o). -- Andrei

Re: Trusted Manifesto

2015-02-09 Thread Meta via Digitalmars-d
On Monday, 9 February 2015 at 20:24:02 UTC, Walter Bright wrote: On 2/9/2015 4:14 AM, Meta wrote: Yes, but is it disabled by default in @trusted code? It is never disabled by default. Okay, I thought it was similar to @system in that respect.

Re: Trusted Manifesto

2015-02-09 Thread Walter Bright via Digitalmars-d
On 2/9/2015 4:14 AM, Meta wrote: Yes, but is it disabled by default in @trusted code? It is never disabled by default.

Re: Trusted Manifesto

2015-02-09 Thread John Colvin via Digitalmars-d
in the references. It involves no language changes, but offers usage guidelines that we believe are workable. Tell us what you think! Trusted Manifesto - Memory safety in D has the usual definition: a memory-safe program never reads

Re: Trusted Manifesto

2015-02-09 Thread John Colvin via Digitalmars-d
On Monday, 9 February 2015 at 11:47:03 UTC, Meta wrote: On Monday, 9 February 2015 at 11:43:00 UTC, Walter Bright wrote: On 2/9/2015 2:54 AM, John Colvin wrote: It seems to me that rules 2 and 3 could be helped along by tooling (compiler or external). Sounds good, but I'd like to see how

Re: Trusted Manifesto

2015-02-09 Thread Dicebot via Digitalmars-d
On Monday, 9 February 2015 at 10:16:48 UTC, Walter Bright wrote: On 2/9/2015 1:36 AM, Dicebot wrote: string toUpper(string s) @safe { char[] r = new char[s.length]; foreach (i, c; s) r[i] = toUpper(c); return cast(string)r; // == unsafe operation } Shouldn't that be `return

Re: Trusted Manifesto

2015-02-09 Thread Meta via Digitalmars-d
On Monday, 9 February 2015 at 11:43:00 UTC, Walter Bright wrote: On 2/9/2015 2:54 AM, John Colvin wrote: It seems to me that rules 2 and 3 could be helped along by tooling (compiler or external). Sounds good, but I'd like to see how this works in practice before going further with it. The

Re: Trusted Manifesto

2015-02-09 Thread Kagamin via Digitalmars-d
Also why safe code is allowed to create unsafe lambdas?

Re: Trusted Manifesto

2015-02-09 Thread Kagamin via Digitalmars-d
On Monday, 9 February 2015 at 08:19:24 UTC, Walter Bright wrote: while not allowing std.conv.trusted escapes in @safe function would be by convention. Can SafeD be enforced given that?

Re: Trusted Manifesto

2015-02-09 Thread Walter Bright via Digitalmars-d
On 2/9/2015 1:36 AM, Dicebot wrote: string toUpper(string s) @safe { char[] r = new char[s.length]; foreach (i, c; s) r[i] = toUpper(c); return cast(string)r; // == unsafe operation } Shouldn't that be `return assumeUnique(r)` instead? assumeUnique does a little more

Re: Trusted Manifesto

2015-02-09 Thread Walter Bright via Digitalmars-d
On 2/9/2015 2:54 AM, John Colvin wrote: It seems to me that rules 2 and 3 could be helped along by tooling (compiler or external). Sounds good, but I'd like to see how this works in practice before going further with it. The nice thing about this proposal is it involves no language changes.

Re: Trusted Manifesto

2015-02-09 Thread Walter Bright via Digitalmars-d
On 2/9/2015 12:53 PM, Meta wrote: On Monday, 9 February 2015 at 20:24:02 UTC, Walter Bright wrote: On 2/9/2015 4:14 AM, Meta wrote: Yes, but is it disabled by default in @trusted code? It is never disabled by default. Okay, I thought it was similar to @system in that respect. @system

Re: Trusted Manifesto

2015-02-09 Thread Meta via Digitalmars-d
On Monday, 9 February 2015 at 12:02:12 UTC, John Colvin wrote: On Monday, 9 February 2015 at 11:47:03 UTC, Meta wrote: On Monday, 9 February 2015 at 11:43:00 UTC, Walter Bright wrote: On 2/9/2015 2:54 AM, John Colvin wrote: It seems to me that rules 2 and 3 could be helped along by tooling

Re: Trusted Manifesto

2015-02-09 Thread Zach the Mystic via Digitalmars-d
On Monday, 9 February 2015 at 11:43:00 UTC, Walter Bright wrote: On 2/9/2015 2:54 AM, John Colvin wrote: It seems to me that rules 2 and 3 could be helped along by tooling (compiler or external). Sounds good, but I'd like to see how this works in practice before going further with it. The

Re: Trusted Manifesto

2015-02-09 Thread Zach the Mystic via Digitalmars-d
On Monday, 9 February 2015 at 18:36:49 UTC, Steven Schveighoffer wrote: On 2/9/15 1:18 PM, Andrei Alexandrescu wrote: On 2/9/15 10:12 AM, Steven Schveighoffer wrote: On 2/9/15 12:57 PM, Andrei Alexandrescu wrote: On 2/9/15 7:48 AM, Steven Schveighoffer wrote: auto result = (() @trusted =

Re: Trusted Manifesto

2015-02-09 Thread Zach the Mystic via Digitalmars-d
On Tuesday, 10 February 2015 at 04:18:16 UTC, Zach the Mystic wrote: On Tuesday, 10 February 2015 at 04:05:35 UTC, Andrei Alexandrescu wrote: On 2/9/15 8:03 PM, Zach the Mystic wrote: You could put the 'trusted' template right in object.d, to save people the awkward burden of importing it from

Re: Trusted Manifesto

2015-02-09 Thread Steven Schveighoffer via Digitalmars-d
On 2/9/15 11:18 PM, Zach the Mystic wrote: On Tuesday, 10 February 2015 at 04:05:35 UTC, Andrei Alexandrescu wrote: On 2/9/15 8:03 PM, Zach the Mystic wrote: You could put the 'trusted' template right in object.d, to save people the awkward burden of importing it from std.conv all the time.

Re: Trusted Manifesto

2015-02-09 Thread Dicebot via Digitalmars-d
On Tuesday, 10 February 2015 at 04:05:35 UTC, Andrei Alexandrescu wrote: On 2/9/15 8:03 PM, Zach the Mystic wrote: You could put the 'trusted' template right in object.d, to save people the awkward burden of importing it from std.conv all the time. But that would be a language change, of

Re: Trusted Manifesto

2015-02-09 Thread Steven Schveighoffer via Digitalmars-d
On 2/10/15 12:06 AM, Dicebot wrote: On Tuesday, 10 February 2015 at 04:05:35 UTC, Andrei Alexandrescu wrote: On 2/9/15 8:03 PM, Zach the Mystic wrote: You could put the 'trusted' template right in object.d, to save people the awkward burden of importing it from std.conv all the time. But that

Re: Trusted Manifesto

2015-02-09 Thread Andrei Alexandrescu via Digitalmars-d
On 2/9/15 9:06 PM, Dicebot wrote: On Tuesday, 10 February 2015 at 04:05:35 UTC, Andrei Alexandrescu wrote: On 2/9/15 8:03 PM, Zach the Mystic wrote: You could put the 'trusted' template right in object.d, to save people the awkward burden of importing it from std.conv all the time. But that