News for hackers. Stuff that matters.
Re:Maybe adding generics to Go is about syntax after all by ape4 on Tuesday September 04, 2018 @10:46AM (#17909389)
C/C++ __LINE__ is unique to a line.
Re:Maybe adding generics to Go is about syntax after all by Someone on Tuesday September 04, 2018 @11:43AM (#17909805)
No, it isn’t, not even within a single file. https://gcc.gnu.org/onlinedocs/cpp/Line-Control.html:

”If you write a program which generates source code, such as the bison parser generator, you may want to adjust the preprocessor’s notion of the current file name and line number by hand.

[…]

#line linenum

linenum is a non-negative decimal integer constant. It specifies the line number which should be reported for the following line of input. Subsequent lines are counted from linenum.

#line linenum filename

linenum is the same as for the first form, and has the same effect. In addition, filename is a string constant. The following line and all subsequent lines are reported to come from the file it specifies, until something else happens to change that. filename is interpreted according to the normal rules for a string constant: backslash escapes are interpreted. This is different from ‘#include’.”

Re:Maybe adding generics to Go is about syntax after all by cyphar on Tuesday September 04, 2018 @10:50AM (#17909423)
I'm not sure you understand what I mean -- the "unique to a line" message is actually a descriptive message not a line number. errors.WithStack gives you the file, line, and function name for free and works with handle -- my complaint is that giving descriptive and stacked error messages will be very hard with handle (but is not fundamentally hard with Rust's map_err even though their error packages aren't as well-developed as Go's from my experience).