-
-
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
Make tilde automatically quote its arguments #4882
Comments
I'm on board with this. I think that what it should do is invoke the |
What's the current scope defined as? If I give a definition in DataFrames of |
Depends on the usual scoping rules I guess. Maybe rewrite |
or rather |
Oops. Sorry. |
I use
But that usage is restricted to function signatures that are wrapped with the When it comes to how the right
I would lean toward the former. The latter feels needlessly complex and too much like monkey patching. |
I could parse this as |
@JeffBezanson: When would it be lowered? After the AST has been converted from surface syntax? |
I would vote for parsing as |
The macro expander would have to treat |
@kmsquire: Non-macro uses should be possible by defining your
which makes |
Thanks, Toivoh and Jeff. |
If people are happy with DataFrames being "in charge" of |
Thinking about this a little more, |
Sorry for being dense, but Debug.jl uses tilde internally, not doesn't export it? If not, how would I use both DataFrames and Debug? |
No problem, I realize that I wasn't very clear. Debug.jl doesn't use tilde at all, but I want it to be able to debug code that does. To do that, it has to expand all macros in instrumented code to make sure that it doesn't miss any variable declarations or possible trap points. I guess that the DataFrames definition of |
Thanks for helping me understand. I guess my original concern that people may step on each other's toes still holds, but I'd rather we move forward with something like |
I can add this easily. |
In model formulas there are very few cases of multiple tildes and I don't think the issue would arise. I found a use for a If a decision is needed I would vote for |
What are we gonna do with the current use of |
It will stay the same. |
How a out varargs parsing instead of associative binary? |
That's the third option above. |
Sweet! Thank you! -- John
|
Oh, right. That then. |
Is this feature somehow reserved? Is it documented?
I guess the answer is that it must be reserved, but I would like to be sure. |
No, it's not reserved for DataFrames. You simply get whatever definition of |
That said, if you use this in a different way, you should probably advertise that your package is not compatible with DataFrames, since it would break things like GLM. Having worked with this for a while, I think it would be reasonable to have it always return a type that behaves like |
Thanks for the answers. I'm not planning to use it in any way, that was just to clarify my view of the language :) Thanks. |
Is there a good reason this couldn't have been done as |
@tkelman, I brought this up also... and was shot down... but I still think this deserves a breaking change to stick the |
@tkelman, I would support getting rid of the specialized parsing of |
That is good to know, thanks. Is DataFrames the only package that currently has an implementation of the |
I think every package that does linear regression uses that notation, so it likely affects MixedModels and NLReg as well. |
I just today found out about this is oddball feature. Have people thought about the future of this, lately? I wonder if we could have @~ defined in base to go to some overloadable function, so it can be shared between many packages? |
|
Hmm... OK I was just speculating. For me - it would be nice to have something both aware of expressions and of the types of things around it. Or have general infix macros, or something. Otherwise, as a single special case, this seems rather unlike the rest of the language. |
E.g. This might be something like a generator: |
We're planning on getting rid of this for 0.6. It requires preparing a more julian implementation of the formula dsl in juliastats packages. |
Ok thanks for the update, Tony! |
In the past we've talked about making the tilde operator do something special to make statistical functions look nicer. One simple approach would take
ex1 ~ ex2
and automatically wrap it in a quote call.This would allow us to change clunky interfaces like
glm(:(y ~ x))
into the nicerglm(y ~ x)
.I'd love to see something like this happen for the 0.3 release, since it will allow us to provide a cleaner (and more familiar interface) for a lot of statistical functions. I suspect it wouldn't even be a badly breaking change, since I'm not aware of anyone using the tilde operator except people doing statistics in Julia.
The text was updated successfully, but these errors were encountered: