Semantics of eval

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Semantics of eval

Bill Hart
In the documentation for metaprogramming:


it says:

"Given an expression object, one can cause Julia to evaluate (execute) it at the top level scope — i.e. in effect like loading from a file or typing at the interactive prompt — using the eval function"

But this does not appear to be correct if eval is called programmatically from within a module definition. In fact, any symbols seem to be injected into module scope and do not get injected into top level scope as they would if I had typed at the interactive prompt.

I don't know whether either the documented semantics or the actual semantics in Julia 0.2 are intended. But I just spent over two hours trying to figure out what was happening because the documentation seems to be confusing on this issue.

The downside of injecting them into module scope is that it might be impossible to inject symbols into global scope from within a module, which may be the desired behaviour (I don't care for my application, but initially I wanted the symbols in top level scope).

Bill.

Reply | Threaded
Open this post in threaded view
|

Re: Semantics of eval

Patrick O'Leary
The latest documentation (http://docs.julialang.org/en/latest/manual/metaprogramming/) is the same. I'm not sure whether the current behavior or the documented behavior is the one which is desired. If you have a short code snippet which demonstrates the current behavior, would you mind filing an issue at https://github.com/JuliaLang/julia/issues/new? If you do, please post a link back here to the issue. Thanks!

On Friday, August 1, 2014 8:55:20 AM UTC-5, Bill Hart wrote:
In the documentation for metaprogramming:

<a href="http://docs.julialang.org/en/release-0.2/manual/metaprogramming/" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdocs.julialang.org%2Fen%2Frelease-0.2%2Fmanual%2Fmetaprogramming%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNGHpeIopGkqAc6Rzkz6zR_paaZT2g';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdocs.julialang.org%2Fen%2Frelease-0.2%2Fmanual%2Fmetaprogramming%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNGHpeIopGkqAc6Rzkz6zR_paaZT2g';return true;">http://docs.julialang.org/en/release-0.2/manual/metaprogramming/

it says:

"Given an expression object, one can cause Julia to evaluate (execute) it at the top level scope — i.e. in effect like loading from a file or typing at the interactive prompt — using the eval function"

But this does not appear to be correct if eval is called programmatically from within a module definition. In fact, any symbols seem to be injected into module scope and do not get injected into top level scope as they would if I had typed at the interactive prompt.

I don't know whether either the documented semantics or the actual semantics in Julia 0.2 are intended. But I just spent over two hours trying to figure out what was happening because the documentation seems to be confusing on this issue.

The downside of injecting them into module scope is that it might be impossible to inject symbols into global scope from within a module, which may be the desired behaviour (I don't care for my application, but initially I wanted the symbols in top level scope).

Bill.

Reply | Threaded
Open this post in threaded view
|

Re: Semantics of eval

Bill Hart
I posted a ticket and code snippet here:


I'm not sure what markdown you are using. It didn't seem to honour '''

What is the correct markdown for quoting Julia code?

Bill.


On 1 August 2014 16:08, Patrick O'Leary <[hidden email]> wrote:
The latest documentation (http://docs.julialang.org/en/latest/manual/metaprogramming/) is the same. I'm not sure whether the current behavior or the documented behavior is the one which is desired. If you have a short code snippet which demonstrates the current behavior, would you mind filing an issue at https://github.com/JuliaLang/julia/issues/new? If you do, please post a link back here to the issue. Thanks!


On Friday, August 1, 2014 8:55:20 AM UTC-5, Bill Hart wrote:
In the documentation for metaprogramming:


it says:

"Given an expression object, one can cause Julia to evaluate (execute) it at the top level scope — i.e. in effect like loading from a file or typing at the interactive prompt — using the eval function"

But this does not appear to be correct if eval is called programmatically from within a module definition. In fact, any symbols seem to be injected into module scope and do not get injected into top level scope as they would if I had typed at the interactive prompt.

I don't know whether either the documented semantics or the actual semantics in Julia 0.2 are intended. But I just spent over two hours trying to figure out what was happening because the documentation seems to be confusing on this issue.

The downside of injecting them into module scope is that it might be impossible to inject symbols into global scope from within a module, which may be the desired behaviour (I don't care for my application, but initially I wanted the symbols in top level scope).

Bill.


Reply | Threaded
Open this post in threaded view
|

Re: Semantics of eval

Ivar Nesje
Correct syntax is backticks
```julia

```

kl. 16:18:33 UTC+2 fredag 1. august 2014 skrev Bill Hart følgende:
I posted a ticket and code snippet here:

<a href="https://github.com/JuliaLang/julia/issues/7807" target="_blank" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2FJuliaLang%2Fjulia%2Fissues%2F7807\46sa\75D\46sntz\0751\46usg\75AFQjCNEU-crzMhyX-Q_Mf2pUuHpxITWROg';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2FJuliaLang%2Fjulia%2Fissues%2F7807\46sa\75D\46sntz\0751\46usg\75AFQjCNEU-crzMhyX-Q_Mf2pUuHpxITWROg';return true;">https://github.com/JuliaLang/julia/issues/7807

I'm not sure what markdown you are using. It didn't seem to honour '''

What is the correct markdown for quoting Julia code?

Bill.


On 1 August 2014 16:08, Patrick O'Leary <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="XuQ6Eva6TlYJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">patrick...@...> wrote:
The latest documentation (<a href="http://docs.julialang.org/en/latest/manual/metaprogramming/" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdocs.julialang.org%2Fen%2Flatest%2Fmanual%2Fmetaprogramming%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHdvHRNqHrkBW6Upo3OJYZ6YuKyyw';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdocs.julialang.org%2Fen%2Flatest%2Fmanual%2Fmetaprogramming%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHdvHRNqHrkBW6Upo3OJYZ6YuKyyw';return true;">http://docs.julialang.org/en/latest/manual/metaprogramming/) is the same. I'm not sure whether the current behavior or the documented behavior is the one which is desired. If you have a short code snippet which demonstrates the current behavior, would you mind filing an issue at <a href="https://github.com/JuliaLang/julia/issues/new" target="_blank" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2FJuliaLang%2Fjulia%2Fissues%2Fnew\46sa\75D\46sntz\0751\46usg\75AFQjCNFnFiCa4jmo8e7oB99GsjJ9IKKEzQ';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2FJuliaLang%2Fjulia%2Fissues%2Fnew\46sa\75D\46sntz\0751\46usg\75AFQjCNFnFiCa4jmo8e7oB99GsjJ9IKKEzQ';return true;">https://github.com/JuliaLang/julia/issues/new? If you do, please post a link back here to the issue. Thanks!


On Friday, August 1, 2014 8:55:20 AM UTC-5, Bill Hart wrote:
In the documentation for metaprogramming:

<a href="http://docs.julialang.org/en/release-0.2/manual/metaprogramming/" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdocs.julialang.org%2Fen%2Frelease-0.2%2Fmanual%2Fmetaprogramming%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNGHpeIopGkqAc6Rzkz6zR_paaZT2g';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdocs.julialang.org%2Fen%2Frelease-0.2%2Fmanual%2Fmetaprogramming%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNGHpeIopGkqAc6Rzkz6zR_paaZT2g';return true;">http://docs.julialang.org/en/release-0.2/manual/metaprogramming/

it says:

"Given an expression object, one can cause Julia to evaluate (execute) it at the top level scope — i.e. in effect like loading from a file or typing at the interactive prompt — using the eval function"

But this does not appear to be correct if eval is called programmatically from within a module definition. In fact, any symbols seem to be injected into module scope and do not get injected into top level scope as they would if I had typed at the interactive prompt.

I don't know whether either the documented semantics or the actual semantics in Julia 0.2 are intended. But I just spent over two hours trying to figure out what was happening because the documentation seems to be confusing on this issue.

The downside of injecting them into module scope is that it might be impossible to inject symbols into global scope from within a module, which may be the desired behaviour (I don't care for my application, but initially I wanted the symbols in top level scope).

Bill.


Reply | Threaded
Open this post in threaded view
|

Re: Semantics of eval

Bill Hart
Thanks, I think it is corrected now.


On 1 August 2014 16:20, Ivar Nesje <[hidden email]> wrote:
Correct syntax is backticks
```julia

```

kl. 16:18:33 UTC+2 fredag 1. august 2014 skrev Bill Hart følgende:
I posted a ticket and code snippet here:


I'm not sure what markdown you are using. It didn't seem to honour '''

What is the correct markdown for quoting Julia code?

Bill.


On 1 August 2014 16:08, Patrick O'Leary <[hidden email]> wrote:
The latest documentation (http://docs.julialang.org/en/latest/manual/metaprogramming/) is the same. I'm not sure whether the current behavior or the documented behavior is the one which is desired. If you have a short code snippet which demonstrates the current behavior, would you mind filing an issue at https://github.com/JuliaLang/julia/issues/new? If you do, please post a link back here to the issue. Thanks!


On Friday, August 1, 2014 8:55:20 AM UTC-5, Bill Hart wrote:
In the documentation for metaprogramming:


it says:

"Given an expression object, one can cause Julia to evaluate (execute) it at the top level scope — i.e. in effect like loading from a file or typing at the interactive prompt — using the eval function"

But this does not appear to be correct if eval is called programmatically from within a module definition. In fact, any symbols seem to be injected into module scope and do not get injected into top level scope as they would if I had typed at the interactive prompt.

I don't know whether either the documented semantics or the actual semantics in Julia 0.2 are intended. But I just spent over two hours trying to figure out what was happening because the documentation seems to be confusing on this issue.

The downside of injecting them into module scope is that it might be impossible to inject symbols into global scope from within a module, which may be the desired behaviour (I don't care for my application, but initially I wanted the symbols in top level scope).

Bill.