> I'm not sure why you need eval to catch syntax errors
Explained in the first post. (A clipboard link between MS Word and the
Julia console.)
> global variables are almost always a terrible idea
I wrote " these look terrible". I am glad, you agree.
> all exceptions can be caught (and examined) in a try/catch block
Not in the Julia console. Try this
~~~
try eval(quote :pasted-text) end)
catch
println("caught!")
end
~~~
> it is fairly trivial to implement your own REPL
Not to a noob. This is why I asked the questions in the first place. Would
you mind giving some details?
(I could not find an easy way to read-write to a Pipe or IOBuffer from an
AutoHotkey script or use named Windows pipes from Julia. Then, how can I
share the information to establish a communication channel? Possibly I can
write a dll in C and call its function from AutoHotkey, but I would still
need help with such C functions. Anyone..?)
My current solution needs only a script of less than 20 lines, and nothing
written in Julia (just using the console). Can you suggest anything
comparable in complexity?
> err is cleared every time something is "available" on the stream
Correct. But it is the *assignment* to err that removes the rest after the
first control characters. As I wrote, "If I print out
"readavailable(rderr)" it has good information about the error", which is
lost when assigned to "err". I wanted to keep that info, but apparently a
null character or something received terminates the assignment. I asked for
suggestions to keep the rest. Can you help?
On Sunday, March 9, 2014 12:44:49 AM UTC-7, Jameson wrote:
>
> 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]<javascript:>
> > 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...
>>
>>
>>
>