I just wondered whether it would be feasible to implement something like
@problem begin
minimize: f(x)
subject to:
g1(x) = a
g2(x) <= b
end
or similar to work properly. Essentially this is nothing but fancy syntax for a constructor of a ‘problem’ struct, is it not?
Are you aware of docs/tutorials of how to achieve this kind of domain specific language?
Also, I was thinking that this would be nice to have in JuMP as a more ‘literate’ way of specifying models.
Thanks for the link!
So, there is no way of actually extending the language syntax via macros - I can only modify valid Julia expressions? I could thus only manually parse strings directly?
If you want a DSL that doesn’t have to be parsable Julia code then you can write it using string macros. One big example for this is MATLAB.jl where it uses string macros instead of “standard macros” since not all MATLAB code parses as Julia code.
The advantage of a standard macro is that it parses as a Julia AST which makes it easy to handle. The disadvantage is that it has to be able to parse into an AST. The advantage of a string macro is that it can literally be applied to any string. The disadvantage is that then you have to parse it all yourself.