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

Rename ^ to syms #125

Closed
pdeffebach opened this issue Mar 6, 2019 · 7 comments
Closed

Rename ^ to syms #125

pdeffebach opened this issue Mar 6, 2019 · 7 comments
Milestone

Comments

@pdeffebach
Copy link
Collaborator

^() is currently used to refer to a symbol on its own. for example,

df @> transform(x = :b) will make a new column :x which looks like the column :b, while

df @> transform(x = ^(:b)) makes a new column :x and fills it with the symbol :b. There is nothing about ^() that indicates this behavior. I propose renaming it to syms, because it escapes Symbols and has the same number of letters as cols.

@nalimilan
Copy link
Member

Doesn't JuliaDBMeta use cols for this? Cc: @piever

@piever
Copy link

piever commented Mar 25, 2019

cols is used to recognize things that evaluate to a symbol, say::

a = :SepalLength
@with iris cols(a)

Whereas ^ is to escape something to be used as a symbol, for example @map iris ^(:a) will return a column full of the symbol :a.

I'm not sure I agree with the proposed renaming. ^ can escape a whole expression and not only a symbol (it basically takes it out of the macro and evaluates it as is), so the name syms is not completely correct. If anything, for consistency I'd be in favor of adding a infix operator version of cols, say @with iris $a, which is in some sense interpolation, in that a is evaluated before replacing symbols with columns.

@nalimilan
Copy link
Member

Got it. Yes, $ for cols kind of makes sense. Maybe we could use esc for ^?

(I still kind of wish we treated all names as columns by default, so that we wouldn't need to escape symbols...)

@pdeffebach
Copy link
Collaborator Author

Got it. Yes, $ for cols kind of makes sense. Maybe we could use esc for ^?

This is okay, but cols also "escapes" the input by evaluating what's inside.

a = :x 
@transform(df, newcol = cols(a)

which is the same as

@transform(df, newcol = :x) # the column `:x` in df. 

Basically we have two divergent ways to escape the variable a.

(I still kind of wish we treated all names as columns by default, so that we wouldn't need to escape symbols...)

Don't we do this already? Or do you mean full tidy evaluation?

@nalimilan
Copy link
Member

So what's the conclusion here?

@pdeffebach pdeffebach reopened this Feb 21, 2021
@pdeffebach
Copy link
Collaborator Author

It's weird that we have cols instead of col... But we should rename this to syms for consistency.

@pdeffebach pdeffebach added this to the 1.0 milestone Mar 7, 2021
@pdeffebach
Copy link
Collaborator Author

Closing this, ^() is fine, and now that we use $ intead of cols it doesn't make sense to have syms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants