If you want to disable the automatic @doc then you can append a ; to the string or nest the expressions in a begin ... end block:
"hello";
3.142
begin
"hello"
3.142
end
— Mike
I agree with MDC Francis that this is kind of odd. Is it common to doc arbitrary numbers? Supporting this isnt necessary to doc MathConsts...
(it also didn't seem to work properly for ints or floats when I tried -- the doc was added to meta, but help didn't seem to find it).
Is it common to doc arbitrary numbers?
I can’t see much use for documenting things like that either. We could either throw an error in @doc if you try to document a number or change the parser to ignore cases such as that. I’d suspect it would be simpler to fix up @doc rather than the parser.
— Mike
help?> parse
search: parse parseip parseint parsefloat ParseError sparse sparsevec
parse(str, start; greedy=true, raise=true)
Parse the expression string and return an expression (which could later be
passed to eval for execution). start is the index of the first character to
start parsing. If greedy is true (default), parse will try to consume as
much input as it can; otherwise, it will stop as soon as it has parsed a
valid expression. Incomplete but otherwise syntactically valid expressions
will return Expr(:incomplete, "(error message)"). If raise is true
(default), syntax errors other than incomplete expressions will raise an
error. If raise is false, parse will return an expression that will raise an
error upon evaluation.
However, this form does not return an expression, it always returns a tuple, with the expression as the first part, and the position in the string where it stopped parsing as the second part.
julia> "hello" 2.3
hello
julia> "hello" (x)->x+1
WARNING: deprecated syntax "hello (".
Use "hello(" instead.
ERROR: syntax: ""hello"(x)" is not a valid function argument name
julia> "hello" z() = 1
z (generic function with 1 method)
julia> "hello" "world"
hello
julia> "hello" "world" "again"
ERROR: syntax: extra token """ after end of expression
julia> "hello" type foo end
julia>
julia> function bar()
"hello" 1.23
ERROR: syntax: extra token "1.23" after end of expression
julia> "hello" x = 2 hello