Re: Trying to search a range

2021-07-02 Thread Kevin Bailey via Digitalmars-d-learn
On Saturday, 3 July 2021 at 01:15:20 UTC, Paul Backus wrote: The error message here is actually telling you exactly what the problem is: `findSplit` requires a forward range, but the range returned by `File.byLine` is not a forward range, just an input range. Hey Paul, Thanks for the

Re: Trying to search a range

2021-07-02 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 3 July 2021 at 00:29:23 UTC, Kevin Bailey wrote: Unfortunately, ldc2 is saying: ``` split.d(8): Error: template std.algorithm.searching.findSplit cannot deduce function from argument types !()(ByLineImpl!(char, char), string), candidates are:

Trying to search a range

2021-07-02 Thread Kevin Bailey via Digitalmars-d-learn
Sorry if this is too simple of a question, but I'm trying to simply find a blank line in a file. I'm doing something like: ``` auto file = File("somefile"); auto r = file.byLine(); auto tup = r.findSplit(""); // tup[0] would contain the range before the line, // tup[2] would contain the range

Re: how much "real-life" code can be marked @safe ?

2021-07-02 Thread tsbockman via Digitalmars-d-learn
(Responding out of order:) On Friday, 2 July 2021 at 00:26:52 UTC, someone wrote: But when you start attempting to declare @safe chunks of code that actually DO things ... well, it seems end-of-the-story. If you find yourself unable to get real work done in `@safe` code, this is almost

Re: how much "real-life" code can be marked @safe ?

2021-07-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/1/21 8:26 PM, someone wrote: ... just wondering: I am writing pretty trivial code, nothing out of the ordinary, and attempted to check how much of it could be marked safe ... It should be quite a bit. - Lots of tiny common library functions are pretty easy - Getter/Setter properties

Re: Printing Tuple!(...)[] using for loop?

2021-07-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/2/21 12:21 AM, Kirill wrote: I have a `Tuple!(string, ..., string)[] data` that I would like to print out: `a   b   c` `1   2   3` `4   5   6`     Furthermore, I want to be able to print any N rows and M columns of that table. For instance:     `b   c`     `2   3`     or

Re: Printing Tuple!(...)[] using for loop?

2021-07-02 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 2 July 2021 at 04:21:24 UTC, Kirill wrote: I have a `Tuple!(string, ..., string)[] data` If there are only strings in the tuple, it could be simplified by making it a static array of strings instead. The compile-time index issue would go away. —Bastiaan

Re: how much "real-life" code can be marked @safe ?

2021-07-02 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 2 July 2021 at 00:26:52 UTC, someone wrote: ... just wondering: ... Imho, if you want all of the app to be safe, and you cannot avoid unsafe code, then there are two choices: 1. Mark the method doing unsafe stuff as @trusted, or pieces of code which are unsafe with trusted lambda

Re: Printing Tuple!(...)[] using for loop?

2021-07-02 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 2 July 2021 at 04:21:24 UTC, Kirill wrote: ... 1. use static foreach for tuple loop. 2. start column and end column should be known at compile time. Either make them immutable, or as enum constant, or pass them as an template argument. Tuple is basically a wrapper over built in