A variation of issue 11977?

2021-01-21 Thread kdevel via Digitalmars-d-learn
~~~gotoskip.d int main () { string[string] aa; goto A; // line 4 aa["X"] = "Y";// line 5 A: return 0; } ~~~ $ dmd gotoskip.d gotoskip.d(4): Error: goto skips declaration of variable gotoskip.main.__aaval2 at gotoskip.d(5) What's wrong here? Only found Issue 11

opIndex negative index?

2021-01-21 Thread cerjones via Digitalmars-d-learn
I have an iterator that steps along a 2D vector path command by command and uses opIndex to give access to the points for the current command. The issue is that there's a shared point between commands, so when the iterator is on a given command, it also needs to also allow access to the end poi

Re: A variation of issue 11977?

2021-01-21 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 21 January 2021 at 13:55:48 UTC, kdevel wrote: ~~~gotoskip.d int main () { string[string] aa; goto A; // line 4 aa["X"] = "Y";// line 5 A: return 0; } ~~~ $ dmd gotoskip.d gotoskip.d(4): Error: goto skips declaration of variable gotoskip.main.__aav

Re: A variation of issue 11977?

2021-01-21 Thread kdevel via Digitalmars-d-learn
On Thursday, 21 January 2021 at 13:55:48 UTC, kdevel wrote: goto A; // line 4 aa["X"] = "Y";// line 5 A: Creating a scope { aa["X"] = "Y"; } // line 5 works around the issue.

Re: opIndex negative index?

2021-01-21 Thread IGotD- via Digitalmars-d-learn
On Thursday, 21 January 2021 at 14:00:28 UTC, cerjones wrote: I have an iterator that steps along a 2D vector path command by command and uses opIndex to give access to the points for the current command. The issue is that there's a shared point between commands, so when the iterator is on a gi

Re: opIndex negative index?

2021-01-21 Thread cerjones via Digitalmars-d-learn
On Thursday, 21 January 2021 at 14:25:41 UTC, IGotD- wrote: On Thursday, 21 January 2021 at 14:00:28 UTC, cerjones wrote: Not possible, indexes are of type size_t which is unsigned. If you want negative indexes you need to wrap arrays in your own implementation and offset 0 so that negative in

Re: A variation of issue 11977?

2021-01-21 Thread kdevel via Digitalmars-d-learn
On Thursday, 21 January 2021 at 13:55:48 UTC, kdevel wrote: [...] created https://issues.dlang.org/show_bug.cgi?id=21571

Re: opIndex negative index?

2021-01-21 Thread IGotD- via Digitalmars-d-learn
On Thursday, 21 January 2021 at 14:47:38 UTC, cerjones wrote: ohreally? I thought you were talking about the built in arrays.

Re: opIndex negative index?

2021-01-21 Thread IGotD- via Digitalmars-d-learn
On Thursday, 21 January 2021 at 15:49:02 UTC, IGotD- wrote: On Thursday, 21 January 2021 at 14:47:38 UTC, cerjones wrote: ohreally? I thought you were talking about the built in arrays. Since you create your own implementation just as you showed you are basically free to do anything. That

Re: A variation of issue 11977?

2021-01-21 Thread z via Digitalmars-d-learn
On Thursday, 21 January 2021 at 14:11:15 UTC, kdevel wrote: Creating a scope works around the issue. Another way to work around the issue is to use «asm {jmp label;}» (replace jmp by whatever equivalent is there on the target architecture.) Yes it's ugly, but it bypasses the arbitrary limita

Re: opIndex negative index?

2021-01-21 Thread cerjones via Digitalmars-d-learn
On Thursday, 21 January 2021 at 15:55:02 UTC, IGotD- wrote: On Thursday, 21 January 2021 at 15:49:02 UTC, IGotD- wrote: On Thursday, 21 January 2021 at 14:47:38 UTC, cerjones wrote: ohreally? I thought you were talking about the built in arrays. Since you create your own implementation jus

std.algorithm.splitter on a string not always bidirectional

2021-01-21 Thread Steven Schveighoffer via Digitalmars-d-learn
auto sp1 = "a|b|c".splitter('|'); writeln(sp1.back); // ok auto sp2 = "a.b|c".splitter!(v => !isAlphaNum(v)); writeln(sp2.back); // error, not bidirectional Why? is it an oversight, or is there a good reason for it? -Steve

Re: opIndex negative index?

2021-01-21 Thread tsbockman via Digitalmars-d-learn
On Thursday, 21 January 2021 at 14:00:28 UTC, cerjones wrote: I'm a bit unsure if this is reasonable or not. Thoughts? Signed indexes are fine, if there is a principled reason to use them. Just make sure that you are consistent by making `length`, `opDollar`, etc. use signed types, as well.

Re: std.algorithm.splitter on a string not always bidirectional

2021-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 21, 2021 at 05:43:37PM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: > auto sp1 = "a|b|c".splitter('|'); > > writeln(sp1.back); // ok > > auto sp2 = "a.b|c".splitter!(v => !isAlphaNum(v)); > > writeln(sp2.back); // error, not bidirectional > > Why? is it an oversight,

Re: isCallable fails

2021-01-21 Thread tsbockman via Digitalmars-d-learn
On Thursday, 21 January 2021 at 05:20:27 UTC, frame wrote: I was not asking here to re-produce my code or debug since it cannot provide a snippet if I do not know what could cause the error. Generally, I don't need to know what causes an error in order to produce an MCVE. I have successfully

Re: isCallable fails

2021-01-21 Thread tsbockman via Digitalmars-d-learn
On Friday, 22 January 2021 at 00:59:32 UTC, tsbockman wrote: 2) Remove, simplify, or mock up/stub out (like for unit tests) some large chunk of the remaining code in the program, from a part of the program that I *think* is unrelated to the error. 3) Re-test the program. a) If the failure g

Re: isCallable fails

2021-01-21 Thread frame via Digitalmars-d-learn
On Friday, 22 January 2021 at 00:59:32 UTC, tsbockman wrote: Generally, I don't need to know what causes an error in order to produce an MCVE. I have successfully done so on many occasions. It's annoying and slow, but usually very possible. I know that I have to debug it myself, but if somebo

Re: isCallable fails

2021-01-21 Thread tsbockman via Digitalmars-d-learn
On Friday, 22 January 2021 at 02:18:11 UTC, frame wrote: Anyway. It was a simple question not a prove that there is a bug in the compiler. isCallable is intended to either evaluate to a boolean, or give a clear compile-time error message. Since it did neither of those things for you, I suspec

Re: isCallable fails

2021-01-21 Thread frame via Digitalmars-d-learn
On Friday, 22 January 2021 at 02:43:44 UTC, tsbockman wrote: No, we're just used to helping each other get to the bottom of things like this. No one asked you for anything different from what we generally expect of each other in this context. This specific expectation mostly exists because, of

Re: isCallable fails

2021-01-21 Thread tsbockman via Digitalmars-d-learn
On Friday, 22 January 2021 at 03:08:23 UTC, frame wrote: It's like asking your mechanican if he can guess what's causing the weird sound in the car and he replies with: why didn't you disassemble your car already? Cars are mass-produced copies of a relatively small number of rather similar de

Re: std.algorithm.splitter on a string not always bidirectional

2021-01-21 Thread Ali Çehreli via Digitalmars-d-learn
On 1/21/21 4:51 PM, H. S. Teoh wrote: > But I wouldn't be surprised if there was some > surprising corner case for which this doesn't work / would have onerous > characteristics. Likely. :) Here is one for uniq.back, which includes a link at the bottom for zip.back: https://issues.dlang.org

Re: std.algorithm.splitter on a string not always bidirectional

2021-01-21 Thread Jon Degenhardt via Digitalmars-d-learn
On Thursday, 21 January 2021 at 22:43:37 UTC, Steven Schveighoffer wrote: auto sp1 = "a|b|c".splitter('|'); writeln(sp1.back); // ok auto sp2 = "a.b|c".splitter!(v => !isAlphaNum(v)); writeln(sp2.back); // error, not bidirectional Why? is it an oversight, or is there a good reason for it? -S

Re: std.algorithm.splitter on a string not always bidirectional

2021-01-21 Thread Jon Degenhardt via Digitalmars-d-learn
On Friday, 22 January 2021 at 05:51:38 UTC, Jon Degenhardt wrote: On Thursday, 21 January 2021 at 22:43:37 UTC, Steven Schveighoffer wrote: auto sp1 = "a|b|c".splitter('|'); writeln(sp1.back); // ok auto sp2 = "a.b|c".splitter!(v => !isAlphaNum(v)); writeln(sp2.back); // error, not bidirectio

Re: isCallable fails

2021-01-21 Thread frame via Digitalmars-d-learn
On Friday, 22 January 2021 at 03:40:40 UTC, tsbockman wrote: Cars are mass-produced copies of a relatively small number of rather similar designs, and mechanics' customers *pay them* to understand and fix their cars so that the customers don't have to. I knew this argument comes... Neverthe