I agree line numbers have been a persistent problem in julia. In a language 
that inlines as aggressively as julia, and uses macros and metaprogramming to 
generate code, it's not a trivial problem---in some cases you might even 
wonder what "line number" really means.

Fortunately, you'll be pleased to hear that, due to some fantastic work by 
multiple people, in the current development version of julia your example 
gives the following:

julia> include("/tmp/linenumbers.jl")
ERROR: LoadError: ArgumentError: invalid type for argument a in method 
definition for foo at /tmp/linenumbers.jl:5
 in include(::ASCIIString) at ./boot.jl:234
 in include_from_node1(::ASCIIString) at ./loading.jl:417
 in eval(::Module, ::Any) at ./boot.jl:237
while loading /tmp/linenumbers.jl, in expression starting on line 4

Not only is the error message much easier to interpret, but every one of those 
line numbers is correct. This appears to hold generally---in recent julia-0.5 
builds, I have yet to notice an incorrect line number anywhere. One could 
construct examples where code is built up by expressions that (deliberately or 
not) get this wrong, but for any "typical" usage this appears to be fixed.

Best,
--Tim

On Friday, April 15, 2016 07:01:05 PM Peter Kovesi wrote:
> Sheehan, That's a very nice looking course but I think you are very brave
> to use Julia at this stage.
> I love the language but (at this stage of the language's development) the
> error reporting is highly problematic.  For example this morning I made a
> classic mistake
> 
> function foo(a::real)     # Should have been:   function foo(a::Real)
>  ...
> end
> 
> The function was defined at line 998, the error was reported at line 433,
>  565 lines away!  The message was
> "ERROR: LoadError: TypeError: Tuple: in parameter, expected Type{T}, got
> Function"
> 
> Good luck to your students!
> 
> Working in Julia requires a practice of defensive incremental coding in the
> extreme.  Every few lines of code that are added need to be tested before
> carrying on.  That way you know that any errors are in the few lines of
> code that were just added and not at whatever spurious location was being
> suggested.
> 
> Let me say again I love the language.  However the error reporting is a
> source of extreme frustration to me.
> 
> A key pathway to getting Julia more widely adopted would be for it to be
> used for teaching purposes.  However, at the moment I fear that any attempt
> to do so would surely end in tears.
> 
> Peter Kovesi
> 
> On Friday, April 15, 2016 at 10:17:40 AM UTC+8, Sheehan Olver wrote:
> > I'm currently lecturing the course MATH3076/3976 Mathematical Computing at
> > U. Sydney in Julia, and thought that others may be interested in the
> > resources I've provided:
> > 
> > http://www.maths.usyd.edu.au/u/olver/teaching/MATH3976/
> > 
> > The lecture notes and labs are all Jupyter notebooks.  I've also included
> > a "cheat sheet" of Julia commands used in the course
> > 
> > 
> > http://nbviewer.jupyter.org/url/www.maths.usyd.edu.au/u/olver/teaching/MAT
> > H3976/cheatsheet.ipynb
> > 
> > The course is ongoing (it's about half through) and will continue to take
> > shape, but any feedback is of course welcome!
> > 
> > 
> > Sheehan Olver

Reply via email to