digitalmars.D.learn - safe console input?
- XavierAP (8/8) Mar 09 2017 I was surprised by a compiler message saying that
- Adam D. Ruppe (2/4) Mar 09 2017 Just wrap it in a @trusted function.
- XavierAP (7/8) Mar 09 2017 I knew this answer already of course ;) but I take it as implying
- Jack Stouffer (2/10) Mar 09 2017 Its use of __gshared. Making it shared is non trivial.
I was surprised by a compiler message saying that std.stdio.readln() (and specifically the overload without arguments) is not safe but system. Actually I was using it only to pause execution until the user presses Enter. So how else could I do this within a safe environment? And more generally, is it possible to get user console input in a safe way?
Mar 09 2017
On Thursday, 9 March 2017 at 22:53:59 UTC, XavierAP wrote:And more generally, is it possible to get user console input in a safe way?Just wrap it in a trusted function.
Mar 09 2017
On Thursday, 9 March 2017 at 23:55:35 UTC, Adam D. Ruppe wrote:Just wrap it in a trusted function.I knew this answer already of course ;) but I take it as implying that there is no other way. Actually I really wonder why std.stdio.readln() itself is not flagged trusted. I wouldn't think such a function skips any buffer bounds checking, even in -release -- having to wait for user input anyway performance is no issue.
Mar 09 2017
On Friday, 10 March 2017 at 00:42:35 UTC, XavierAP wrote:On Thursday, 9 March 2017 at 23:55:35 UTC, Adam D. Ruppe wrote:Its use of __gshared. Making it shared is non trivial.Just wrap it in a trusted function.I knew this answer already of course ;) but I take it as implying that there is no other way. Actually I really wonder why std.stdio.readln() itself is not flagged trusted. I wouldn't think such a function skips any buffer bounds checking, even in -release -- having to wait for user input anyway performance is no issue.
Mar 09 2017