Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parseJSONValue doesn't work with in params / lvalues #14

Open
Geod24 opened this issue Jun 23, 2015 · 3 comments
Open

parseJSONValue doesn't work with in params / lvalues #14

Geod24 opened this issue Jun 23, 2015 · 3 comments

Comments

@Geod24
Copy link
Member

Geod24 commented Jun 23, 2015

The following fails to compile:

    static void test(in string a, in string b) {
        auto filter = parseJSONValue(a);
        auto obj = parseJSONValue(b);
    }

And so does the following:

 auto filter = parseJSONValue(`{}`);
@s-ludwig
Copy link
Collaborator

The current situation is not quite consistent w.r.t. parseJSONStream here, but parseJSONValue follows std.conv:

  • parseJSONValue takes a reference to an input range and consumes a single JSON value, leaving the rest of the range intact
  • toJSONValue takes an input range by value and expects it to contain exactly one JSON value

Taking this as the basis, parseJSONStream would actually have to be renamed to toJSONStream, but since it parses lazily that doesn't seem to capture the meaning very well.

@Geod24
Copy link
Member Author

Geod24 commented Jun 25, 2015

Wouldn't auto ref be an option here ? From recent N.G. discussions it looks like it's exactly the kind of situation it is used in.

@s-ludwig
Copy link
Collaborator

Yes and no. No, because the semantics are also different between the two: to throws if there is more in the input than a single value (modulo whitespace), while parse just leaves any excessive contents in the input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants