comonicon / Comonicon.jl

Your best CLI generator in JuliaLang
https://comonicon.org
MIT License
282 stars 25 forks source link

[Feature Request] add dependency specification #197

Closed GiggleLiu closed 2 years ago

GiggleLiu commented 2 years ago

If I want to write a script with both GPU and CPU code, then I can avoid using CUDA by using the following grammar.

@cast :(using CUDA) function f(x)
      # some GPU computation
end

@cast function g(x)
      # some CPU computation
end

@main

The @main macro calls the required using statement by inspecting ARG[1].

Roger-luo commented 2 years ago

I think this would be the solution to your feature without adding a new syntax to the package https://github.com/johnnychen94/LazyModules.jl

cc: @johnnychen94

johnnychen94 commented 2 years ago

For CUDA.jl it will almost certainly hit the world-age issue because CuArray is an alien type to the caller world-age. See the discussion in [ANN] Accouncing LazyModules.jl: delay the heavy dependency loading to its first use

Roger-luo commented 2 years ago

OK, that's quite unfortunate... but in general, I feel this is not something Comonicon should support but should be supported by Julia itself unless we can find a way that does not change the syntax.