-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Implement @__LINE__ macro #12727
Conversation
Alternatively, could use the same pattern just for |
Quote of the week! |
👏👏👏! 👍 |
Nice. Probably needs a once over by @JeffBezanson |
A Wouldn't it be simpler just to replace |
That is much nicer. Updated to do so for both (I'm not sure how to document these now -- writing doc strings lead to a "Invalid doc expression" during sysimg build. Removed for now, will open a separate issue if I can't figure it out) |
(if (ts:space? s) | ||
(cond | ||
((eqv? head '__LINE__) (input-port-line (ts:port s))) | ||
((eqv? head '__FILE__) `(call string (quote ,current-filename))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could just be a constant string, (string current-filename)
.
I'm not 100% sure how to make this doc-able either. Maybe we should parse |
This is awesome. You could document them as keywords, which are checked first: julia> Base.Docs.keywords[symbol("@__FILE__")] = "filedoc"
"filedoc"
help?> @__FILE__
search: @__FILE__
"filedoc" |
Perfect, thanks @mbauman. Updated. Implementing |
A filename gets passed through from |
@ihnorton, I think IJulia relies on the |
thefname = "the fname!//\\&\1*" | ||
# passing a second argument to include_string should be reflected by @__FILE__ | ||
@test include_string("test_atsign_file() = @__FILE__", thefname)() == thefname | ||
@test include_string("test_atsign_file() = @__FILE__")() == "string" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No test for @__LINE__
?
Sorry, I misunderstood what was going on with the test failure. This does not change the behavior of with
on master the out of
on this branch:
There are only two packages that use |
I removed the |
... or not, I guess. Just saw the feature freeze announcement. |
@__FILE__() -> AbstractString | ||
|
||
`@__FILE__` expands to a string with the absolute path and file name of the script being run. Returns `nothing` if run from a REPL or an empty string if evaluated by `julia -e <expr>`. | ||
`@__FILE__` expands to a string with the absolute path and file name of the script being run. | ||
Returns `"none"` if run from a REPL or command-line context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this actually change from nothing
to "none"
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ihnorton can you confirm? Just tried it and this looks wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that was left from the proposed change. I'll fix the doc.
On Aug 28, 2015 7:35 PM, "Tony Kelman" [email protected] wrote:
In base/docs/helpdb.jl
#12727 (comment):@__FILE__() -> AbstractString
-
@__FILE__
expands to a string with the absolute path and file name of the script being run. Returnsnothing
if run from a REPL or an empty string if evaluated byjulia -e <expr>
.
+@__FILE__
expands to a string with the absolute path and file name of the script being run.
+Returns"none"
if run from a REPL or command-line context.@ihnorton https://github.com/ihnorton can you confirm? Just tried it
and this looks wrong.—
Reply to this email directly or view it on GitHub
https://github.com/JuliaLang/julia/pull/12727/files#r38254310.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8fb7046 (on the docfix branch)
RFC: Implement @__LINE__ macro
Let's just pretend this got merged before that announcement. |
(upated) Implements
__LINE__
and__FILE__
magic macros returning the line number (integer) and filename (as string) for a given call location.Fixes #8066
This is what happens when you force the riff-raff to learn a little scheme.