> I'm encountering the error "eval cannot be used in a generated function" in Julia 0.5 for code that is working in Julia 0.4.
I feel your pain, Erik! > AFAICT, it remains possible to do dynamic type generation if you (1) print the code that would define the type to a file, and (2) `include` the file. While this is true, is your example meant to be a generated function? If I need to recreate an existing type by calling `create_type_dynamically` again with the same parameters, it won't be free at run-time. Unless we can get it to recompile, and `isdefined()` is `@pure` or (evaluated by inference)... hmm... > The definition of a generated function is "a pure function which computes a function body based solely upon properties of the input argument types". Since `eval` isn't pure, that would violate the definition of what `@generated` is, and therefore it isn't usable. This isn't supposed to be complicated, what an `@generated` function is actually supposed to be allowed to do is just extremely limited, to make sure the system doesn't fall apart on edge cases. Jameson - I suppose most of us think not of Julia as like the C or C++ language standards, but as an implementation. A beautifully hackable implementation, at that! I would assert that the definition of a generated function is written in C++, lisp, Julia, etc. So it seemed to us users that what "pure" meant was in this context was whatever we observed to work: that it should always produce the same output code, and it seemed obvious that the generator itself runs one or more times before the function is called. Side effects that don't cause the compiler to get confused? Well, why not? We can `println` in the generator, and that is rather useful for debugging. In the past months several people have independently come up with the same incredibly useful trick/hack, and there is now a bit of sadness felt that our clever/insane code has died! I'm not saying this is terribly bad. Fixing #265 would be wonderful, and we shouldn't get in the way of that. But Julia has always appeared to be driven by community desires, and I feel these generated types are pretty nifty. Constructive thoughts on any way forward would be greatly appreciated. As would an actual example of this not working as expected in the current implementation of Julia (though I think you may have provided this for planned work on #265??).
