>> 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?
There are potentially a lot of different ways of writing the REPL,
depending on the desired user interaction. At a minimum, you could launch
julia-basic.exe as a subprocess and communicate via a pipe. Windows pipes
are exposed as a type of socket connection so you can connect and/or listen
to them like a normal unix socket.
Mini REPL for STDIN -> clipboard. I'm not sure how you would indicate that
your results are now available on the clipboard.
module REPL_ENV end
begin
orig_out = STDOUT
orig_err = STDERR
out = redirect_stdout()[1]
err = redirect_stderr()[1]
try
line = ""
while true
write(STDIN, "\njulia> ")
line *= readline(STDIN)
try
ex = parse(line,raise=false)
if isa(ex,Expr) && ex.head === :error
# have an error
res = "parse error"
line = "" #XXX: handle the case where more lines of input are expected
instead of clearing line
else
res = eval( REPL_ENV, ex )
line = ""
end
catch ex
Base.display_error(ex, catch_backtrace())
end
write(STDOUT,'\n')
otxt = readavailable(out)
write(STDERR,'\n')
etxt = readavailable(err)
copy = "RESULT: $res\nSTDOUT:\n$otxt\nSTDERR:\n$etxt"
write(orig_out, copy)
clipboard(copy)
end
finally
redirect_stdout(orig_out)
redirect_stderr(orig_err)
end
end
On Sun, Mar 9, 2014 at 8:14 PM, Stefan Karpinski <[email protected]>wrote:
> The former seems to be a bug in parse causing it to raise an error even
> when the raise option is false. I've opened an issue:
> https://github.com/JuliaLang/julia/issues/6089.
>
>
> On Sun, Mar 9, 2014 at 3:55 PM, Laszlo Hars <[email protected]> wrote:
>
>> ...a couple of examples, why eval(quote...end) is better than
>> eval(parse("...")):
>> ~~~
>> julia> eval(parse("x=1
>> x+1"))
>> # -> ERROR: extra token after end of expression
>> # in parse at string.jl:1219
>>
>> julia> eval(quote x=1
>> x+1 end)
>> # -> 2
>> ~~~
>> julia> eval(parse("a = \"ab \"cd\" \"")) # need to escape inside quote
>> chars, somehow
>> # -> ERROR: @cd_str not defined
>> ### what does this error mean???
>>
>> julia> eval(quote a = "ab \"cd\" " end)
>> # -> "ab \"cd\" "
>> ~~~
>>
>
>