Not clear what 0.01f0x is in the Flux docs

I’d argue that it’s bad style to omit the * in this case, since it makes it harder to read the numeric literal. There’s also an inconsistency between float and byte literals for this behavior:

julia> x = 0
0

julia> 0f0x
0.0f0

julia> 0x0x
ERROR: syntax: invalid numeric constant "0x0x"
Stacktrace:
 [1] top-level scope at REPL[14]:0
 [2] eval(::Module, ::Any) at ./boot.jl:331
 [3] eval_user_input(::Any, ::REPL.REPLBackend) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
 [4] run_backend(::REPL.REPLBackend) at /Users/alexames/.julia/packages/Revise/MgvIv/src/Revise.jl:1023
 [5] top-level scope at none:0

julia> 0x0*x
0

…which makes sense, since we need to handle e.g.

julia> a = 2
2

julia> 0x0a
0x0a

…but for the sake of clarity, I would only ever use the implicit multiplication syntax for undecorated numeric literals like 20.0x (never 2e1x).

5 Likes