Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
September 07, 2015 Regression? | ||||
---|---|---|---|---|
| ||||
This used to work in older compiler (might have been v2.067 or v2.066, not older). ``` #!rdmd import std.stdio; import std.json; import std.algorithm; void main() { auto ls = File("../languages.json","r").byLineCopy().joiner.parseJSON(); } ``` Error: c:\D\dmd2\windows\bin\..\..\src\phobos\std\json.d(639): Error: variable std.json.parseJSON!(Result).parseJSON.json has scoped destruction, cannot build closure |
September 07, 2015 Re: Regression? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sebastiaan Koppe | Dammit, i am on windows, DMD32 D Compiler v2.068.0 |
September 08, 2015 Re: Regression? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sebastiaan Koppe | Fixed it by changing into: ``` import std.conv : text; string json = File("../languages.json","r").byLineCopy().joiner.text; auto ls = json.parseJSON(); ``` |
September 08, 2015 Re: Regression? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sebastiaan Koppe | On Tuesday, 8 September 2015 at 04:04:16 UTC, Sebastiaan Koppe wrote:
> Fixed it by changing into:
>
> ```
> import std.conv : text;
> string json = File("../languages.json","r").byLineCopy().joiner.text;
> auto ls = json.parseJSON();
> ```
Why would you read file by line and then merge all into one string? You end up with reading the whole file (well, getting rid of line ends) anyway, so probably the more efficient solution would be just read the whole file at once with std.file.read and cast to string.
|
September 08, 2015 Re: Regression? | ||||
---|---|---|---|---|
| ||||
Posted in reply to FreeSlave | On Tuesday, September 08, 2015 07:12:50 FreeSlave via Digitalmars-d-learn wrote: > On Tuesday, 8 September 2015 at 04:04:16 UTC, Sebastiaan Koppe wrote: > > Fixed it by changing into: > > > > ``` > > import std.conv : text; > > string json = > > File("../languages.json","r").byLineCopy().joiner.text; > > auto ls = json.parseJSON(); > > ``` > > Why would you read file by line and then merge all into one string? You end up with reading the whole file (well, getting rid of line ends) anyway, so probably the more efficient solution would be just read the whole file at once with std.file.read and cast to string. Or just use std.file.readText: http://dlang.org/phobos/std_file.html#readText - Jonathan M Davis |
September 09, 2015 Re: Regression? | ||||
---|---|---|---|---|
| ||||
Posted in reply to FreeSlave | On Tuesday, 8 September 2015 at 07:12:52 UTC, FreeSlave wrote: > On Tuesday, 8 September 2015 at 04:04:16 UTC, Sebastiaan Koppe wrote: >> Fixed it by changing into: >> >> ``` >> import std.conv : text; >> string json = File("../languages.json","r").byLineCopy().joiner.text; >> auto ls = json.parseJSON(); >> ``` > > Why would you read file by line and then merge all into one string? You end up with reading the whole file (well, getting rid of line ends) anyway, so probably the more efficient solution would be just read the whole file at once with std.file.read and cast to string. Thanks for your advice. But that is not what I asked for. The question was, why doesn't this work anymore with the latest (2.068.0 and 2.068.1) compiler: ``` auto ls = File("../languages.json","r").byLineCopy().joiner.parseJSON(); ``` It should. Right? |
December 08, 2015 Re: Regression? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sebastiaan Koppe | On Wednesday, 9 September 2015 at 01:35:26 UTC, Sebastiaan Koppe wrote:
>
> Thanks for your advice. But that is not what I asked for.
>
> The question was, why doesn't this work anymore with the latest (2.068.0 and 2.068.1) compiler:
>
> ```
> auto ls = File("../languages.json","r").byLineCopy().joiner.parseJSON();
> ```
>
> It should. Right?
I just ran into this as well. This seems like a regression.
|
December 08, 2015 Re: Regression? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sebastiaan Koppe | On Wednesday, 9 September 2015 at 01:35:26 UTC, Sebastiaan Koppe wrote: > > Thanks for your advice. But that is not what I asked for. > > The question was, why doesn't this work anymore with the latest (2.068.0 and 2.068.1) compiler: > > ``` > auto ls = File("../languages.json","r").byLineCopy().joiner.parseJSON(); > ``` > > It should. Right? https://issues.dlang.org/show_bug.cgi?id=15423 |
Copyright © 1999-2021 by the D Language Foundation