Skip to content
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

future room for pragmas: ignore %foo syntax? #12492

Closed
StefanKarpinski opened this issue Aug 6, 2015 · 9 comments
Closed

future room for pragmas: ignore %foo syntax? #12492

StefanKarpinski opened this issue Aug 6, 2015 · 9 comments
Labels
needs decision A decision on this change is needed speculative Whether the change will be implemented is speculative

Comments

@StefanKarpinski
Copy link
Member

In light of #12475, we may want to consider ignoring this syntax, which is currently an error (and seems unlikely to ever be wanted for anything else):

julia> %foo
ERROR: syntax: "%" is not a unary operator

We would probably want to just to ignore any line matching r"^\s*%\s*\S". Deciding what if anything such lines should ever mean, can be left for the future, but this leaves the option open to have some kind of backwards-compatible pragma system, in case we find ourselves in situations where tricks like #12491 aren't possible. See also #7449, which proposed a specific meaning for %if, etc.

@StefanKarpinski StefanKarpinski added speculative Whether the change will be implemented is speculative needs decision A decision on this change is needed labels Aug 6, 2015
@StefanKarpinski StefanKarpinski changed the title future room for pragmas: ignore %foo syntax future room for pragmas: ignore %foo syntax? Aug 6, 2015
@JeffBezanson
Copy link
Member

This could cause a lot of confusion since certain other languages use % as the comment character, and this would make that work. Instead we might want to make it an error by default, with the semantics that in the future such statements will either (1) provide some hint to the system, or (2) do nothing. When we add %foo, we'd also add something to Compat.jl that allows %foo but ignores it.

@ScottPJones
Copy link
Contributor

Counter example:

julia> b = 5 ; foo = 2
2

julia> a = (b
       %foo
       )
1

@StefanKarpinski
Copy link
Member Author

That's a pretty pathological case that I'm willing to ignore as vanishingly unlikely to occur in real code.

@StefanKarpinski
Copy link
Member Author

Having a user-extensible list of ignored words / patterns seems reasonable.

@ScottPJones
Copy link
Contributor

I suppose I just instinctively dislike anything that is ambiguous, even if it is unlikely to occur in real code.

@mikewl
Copy link
Contributor

mikewl commented Aug 7, 2015

Syntax aside, what would pragmas be used for?
compile and conditionally parsing code are the two examples given.

I wonder if pragmas could tell the compiler to do more aggressive optimisations - or less depending on your needs.

@lobingera
Copy link

This all looks like trying to find a syntax that can be parsed (even with the std. parser) but not executed/evaluated (i might be wrong here).

But why not turning this around: having a function defined in Base (or Meta) that just creates no code - maybe a return statement only. but is valid in the preprocessing step/stage.

Meta.pragma(:compileflags,'do it')

@StefanKarpinski
Copy link
Member Author

@lobingera, that's a good idea – this doesn't have to be syntactic, it just needs to be a hook that is ignored unless used in a version that understands it. It doesn't really belong in Meta imo, but for this compilation thing, for example @pragma precompile true would be fine as long as @pragma is defined to ignore anything that it doesn't understand – or to look to be extensible via Compat.

@lobingera
Copy link

i just choose Meta, because it's imported by default and somehow has something to do with code generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs decision A decision on this change is needed speculative Whether the change will be implemented is speculative
Projects
None yet
Development

No branches or pull requests

5 participants