[Issue 18172] std.getopt should allow taking parameters by `ref` (like std.format.formattedRead), s.t. it can be used in @safe

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 15 14:38:16 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18172

--- Comment #7 from Jack Stouffer <jack at jackstouffer.com> ---
(In reply to Jonathan M Davis from comment #5)
> You have to compile with -dip1000, which Phobos isn't right now. If I try it
> locally with -dip1000, I get
> 
> q.d(10): Error: scope variable f assigned to non-scope parameter _param_3
> calling std.getopt.getopt!(string, string, bool*, string, string,
> bool*).getopt
> q.d(11): Error: scope variable b assigned to non-scope parameter _param_6
> calling std.getopt.getopt!(string, string, bool*, string, string,
> bool*).getopt
> 
> and I get a similar error if I take the address when passing to getopt like
> you normally would. getopt itself probably needs to have the parameters
> marked with scope to fix that. Regardless, it seems to me that either it's
> possible to tweak getopt to make this work with @safe in -dip1000, or it
> should be discussed with Walter how to improve DIP 1000 to make it work.
> Conceptually, I don't see any reason why getopt couldn't be made to work
> with scope and -dip1000 in @safe, because it doesn't escape the pointers.
> The question is what needs to be done to make it work.

I should have emphized more the fact that I had already modified getopt. I've
attached my changes as a patch

--


More information about the Digitalmars-d-bugs mailing list