GiggleLiu / NiLang.jl

A differential eDSL that can run faster than light and go back to the past.
https://giggleliu.github.io/NiLang.jl/dev
Apache License 2.0
250 stars 16 forks source link

pluto notebook issues #77

Open spinkney opened 3 years ago

spinkney commented 3 years ago
  1. Some of the latex is not rendering

    Screen Shot 2021-09-24 at 7 30 29 AM

    g

  2. Errors resulting when defining functions for all nilang functions

    Screen Shot 2021-09-24 at 7 31 40 AM

julia 1.6.2 NiLang v0.9.1 Pluto v0.16.1

GiggleLiu commented 3 years ago

Oops, the macro is incompatible with Pluto 0.16, it expands the macros so it warns repeated definition of the NiLangCore._typeof function.

@fonsp Do you know any good fix?

fonsp commented 3 years ago

I am definitely missing the context here, but defining multiple for the same function is allowed in pluto since https://github.com/fonsp/Pluto.jl/pull/538 , as long as their types are different. How is the function being defined? Can you post a @macroexpand result?

If you want to hide something from Pluto's analysis: eval(:( #= original code =# ))

GiggleLiu commented 3 years ago

The macroexpand result is

julia> @macroexpand @i function f1(x, y) end
quote
    begin
        $(Expr(:meta, :doc))
        function $(Expr(:where, :(f1(x, y))))
            #= REPL[6]:1 =#
            #= REPL[6]:1 =#
            (x, y)
        end
    end
    if (NiLangCore)._typeof(f1) != (NiLangCore._typeof)(~f1)
        function $(Expr(:where, :((var"##~f1#272"::(NiLangCore._typeof)(~f1))(x, y))))
            #= REPL[6]:1 =#
            #= REPL[6]:1 =#
            (x, y)
        end
    end
end

I think the function name is not analysed correctly, it should be (var"##~f1#272"::(NiLangCore._typeof)(~f1)), rather than NiLangCore._typeof.

fonsp commented 3 years ago

I see, can you post just this last bit as a github issue on pluto? Make sure to give a MWE that does not depend on (being familiar with) NiLang.jl

GiggleLiu commented 3 years ago

I have posted an issue in Pluto's repo. About the first issue, I think it is probably because I used TikzPictures (https://github.com/JuliaTeX/TikzPictures.jl). It requires a latex installation. @spinkney Or I can generate a pdf file in the notebook folder, so that you do not need a latex to show the images, which works better for you?

spinkney commented 3 years ago

@GiggleLiu, either way though it will be easier for people to just run as-is with the pdf files.