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

Parse built-in functions #9

Open
fcollonval opened this issue Jul 19, 2022 · 5 comments
Open

Parse built-in functions #9

fcollonval opened this issue Jul 19, 2022 · 5 comments

Comments

@fcollonval
Copy link

fcollonval commented Jul 19, 2022

Would it be acceptable to add built-in functions as parser statements?

I'm gladly push a PR for this.

@fcollonval fcollonval changed the title Parse bui Parse built-in functions Jul 19, 2022
@marijnh
Copy link
Contributor

marijnh commented Jul 19, 2022

These can be shadowed, since they are just identifiers in the grammar, so I don't think it is a good idea to treat them specially.

def plusOne(abs):
  return abs + 1

plusOne(1)

@krassowski
Copy link

Is there a way for downstream to opt-in or implement these easily? I see the changes in #13 go pretty deep into the grammar and patching these would be rather labours. Could it be an opt-in setting?

@axil
Copy link

axil commented Oct 6, 2023

Here, syntax highlighting serves as a hint that this is a keyword and it should not be shadowed. Without highlighting, it is much easier to shadow it for a newbie.

I teach python to students at a university who happen to be 'fluent' in other programming languages, and it is a common error for them to name variables as 'list', 'str', 'sum', 'min/max', 'id' or 'vars', which are not built-ins in other languages. Of course they will learn it — later — but bad habits are simpler to form than they are to break. There is no easy way for them to see if these names are built-ins or not unless they are highlighted.

I would strongly vote for keeping them highlighted.

@Atcold
Copy link

Atcold commented Nov 28, 2023

Coming here from the same perspective of @axil.
How is one supposed to know a given keyword is reserved if it's not highlighted?

@zzhengnan
Copy link

Another potential data point in favor of this request: All major IDEs/editors highlight built-ins, as does command line IPython.

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

6 participants