On 2014年12月19日 星期五 15:03:51, Jameson Nash <Julia Users <julia-
[email protected]>> wrote:
> by that same token, the AST itself is not a stable API. what's much more
> likely to change however is the ordering and contents of the fields of
> these, and any type, within Base.

Speaking of API stability, is there any official compatibility grantee? I've 
seen a thread on the -dev list about it but didn't find any official 
statement.

In general, I'm aware that these API might change in a new version and I'm 
fine with it as long as it is still possible to do what I need. I'll also 
likely to use LLVM on the remote machine to execute the program and I guess 
that has a much higher API breakage rate than julia.....

> 
> .args[2] needs to be regenerated with any changes you've made anyways, so
> it's easiest to just ignore it. you could manually track all of your
> updates in there, and put together a new function object manually, but it's

Is it possible to do that? Given that evaluating the AST directly does not 
return the function definition itself. (e.g. is it possible to copy the 
closure variables as well by just manipulating some AST's?)

> probably not worthwhile. to be completely safe, I should be checking
> isempty(.args[2][3]), since it's not meaningful to copy a function that
> includes closure variables.
> 

I think it is as meaningful as copying a normal function (which is not very 
much in general) but in my case it is probably too complicated to analyse (at 
least for a start).... Thanks for pointing that out...

> 
> 
> On Fri Dec 19 2014 at 9:28:49 AM Stefan Karpinski <[email protected]>
> 
> wrote:
> > I would add some fair warning: lowered code is not an official API.
> > Documenting it and stabilizing it would be nice, but for now any code that
> > relies on details of code lowering could be fragile.
> > 
> > On Thu, Dec 18, 2014 at 12:01 PM, Yichao Yu <[email protected]> wrote:
> >> Hi,
> >> 
> >> I'm wondering if there's a way to recompile the lowered AST back into a
> >> function and what additional information (other than the module it should
> >> be
> >> evaluate in) is necessary to do that what I've tried and would like to do
> >> is
> >> demonstrated with the code attached. The idea is that I would like to
> >> modify
> >> the code of a function/method before calling it (in this case, I am
> >> replacing
> >> it with the code from another function with the same signature). (In
> >> another
> >> word, the question is how to construct a function from code1 with ast2
> >> and run
> >> it.)
> >> 
> >> It will also be nice if there's more documentation on this "lowered AST"
> >> since
> >> it seems to be very different form the one you get in a function
> >> definition.
> >> (e.g. what is the array in `code_lowered(+, (Float64,
> >> Float64))[1].args[2]`
> >> mean)
> >> 
> >> A brief description of what I want to do. I'm writing a control system
> >> with
> >> dynamic logic. However, since the code might not be running on a single
> >> host,
> >> it is hard to use an existing interpreter to do what I want. Trying to
> >> avoid
> >> inventing yet another language, I hope to use a subset of an existing
> >> language
> >> and somehow transform it into a representation that can be run somewhere
> >> else
> >> and it seems that the inspection and meta programming feature in julia is
> >> very
> >> useful for this. It might be possible to just apply a macro to every
> >> function
> >> / method definition but it will be much harder to write. I would rather
> >> try to
> >> "trace" the excution and use the AST acquired at runtime. For that I
> >> would
> >> like to know more about the lowered AST and possibly how to execute a
> >> modified
> >> version in order to trace recursive / nested function calls. This might
> >> not be
> >> the best way to do it and I'm still in planning stage so any suggestions
> >> on
> >> the design is also welcome.
> >> 
> >> Cheers,
> >> 
> >> Yichao Yu

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to