robertkrimen / otto

A JavaScript interpreter in Go (golang)
http://godoc.org/github.com/robertkrimen/otto
MIT License
7.97k stars 584 forks source link

Is there an equiv of C's __LINE__ ? #528

Open TomOnTime opened 2 weeks ago

TomOnTime commented 2 weeks ago

Oddball question but...

Is there an equiv of C's LINE in Otto?

For example, I'd like to call a function like foo(LINE, param1, param2, param3) so that foo can output an error like, "Function foo called improperly on line X".

Thanks!

stevenh commented 2 weeks ago

Not sure it would make as much sense as in raw JS as that's file based where as code here may not be.

TomOnTime commented 2 weeks ago

It would help to know the line number.

stevenh commented 2 weeks ago

If you ask go the line number that would be the calling reference not the line in the js code.

Have you tried options in native js such as detailed here?

tlimoncelli commented 1 week ago

That gets me closer. Thanks!