I'm not sure why you need eval to catch syntax errors, since it doesn't call parse in the first place. the `parse` function has many configurable arguments, including whether to throw an error or return it, and handling for multiple expressions
global variables are almost always a terrible idea, inherited from a C interface, leading to brittle (and slow) code all exceptions can be caught (and examined) in a try/catch block. I'm not sure why you are having trouble. it is fairly trivial to implement your own REPL (read-eval-parse-loop). this is what IJulia (and the built in readline-repl) do err is cleared every time something is "available" on the stream. in my trials (and expectation), this ends up being the console control characters that are printed at the start of the repl loop (which looks like nothing) On Sun, Mar 9, 2014 at 6:43 AM, Laszlo Hars <[email protected]> wrote: > Your instructions, Isaiah, fixed the IJulia installation problem. It is > working now! Thanks! > > With your help I could get a step closer to a possible solution to my > original problem: catching syntax errors. > ~~~ > err = nothing > rderr,wrerr = redirect_stderr() > > @schedule begin > global err > while(true) > err = readavailable(rderr) > end > end > ~~~ > At this point I paste an expression into the Julia console. If it is > valid, the err global variable stays empty. If there is any error, the err > variable contains something, so I know there was an error. I have to set > "err = nothing" again, and I can go on. > > The only problem is that err contains a meaningless string. If I print out > "readavailable(rderr)" it has good information about the error, but the > assignment to a variable removes all readable text. Can I fix that? Like > printing to a variable instead of a stream? > > All these look terrible. There could be a few nice solutions, if Julia was > modified a bit: > - A function or global variable, lastError, containing the description of > the last error. It can be cleared manually, or automatically when a new > user input is entered. > - A syntax error could be made catch-able in the eval() command > - STDERR could be made redirectable to a memory buffer or regular IOStrem > or a pipe... > > >
