Altering parse/eval behavior without overriding methods in base

question

#1

I have noticed that it is possible to alter how code typed into the REPL is interpreted without overriding methods in base. I am uncertain as to whether or not this is intended behavior but suspect it is not.

julia> macro int128_str(x); "Surprise!"; end
@int128_str (macro with 1 method)

julia> 1111111111111111111111111
"Surprise!"

It appears that Meta.parse does not currently annotate module path information, for example:

julia> Meta.parse("1111111111111111111111111")
:(@int128_str "1111111111111111111111111")

instead of :(Base.@int128_str "1111111111111111111111111")

julia> versioninfo()
Julia Version 1.0.0
Commit 5d4eaca0c9 (2018-08-08 20:58 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, haswell)

#2

That does indeed look incorrect. Perhaps you can even fix it (https://github.com/JuliaLang/julia/blob/05fb47d83915d94912dd3dad783fac037125e07e/src/julia-parser.scm#L411-L443)


#3

If I recall correctly, this was intentional so that you can change the behavior of integer literals in your module if you want to.


#4

If the goal is to allow for changing the behavior of integer literals in your module, then I am not certain that this is the best way of achieving this. It would only work for values in certain size ranges (all of which are greater than Int64).


#5

Yes, I think we can just change this in 1.1. I highly doubt anybody is relying on this (famous last words?)