Proposal: Literal identifiers with backtick #370
              
                Unanswered
              
          
                  
                    
                      mdmcconnell
                    
                  
                
                  asked this question in
                General
              
            Replies: 1 comment 3 replies
-
| Can you show an example of what it may look like? Is it for variable access from env? | 
Beta Was this translation helpful? Give feedback.
                  
                    3 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
My application has a lot of identifiers that use natural language, things like "Section 1-2a", or "2015 Information Table". Currently, expr can not parse these as single token identifiers for various reasons. Possible workarounds for me include: make ad-hoc subsitutions to my identifiers, such as "Section_1_2a", though that will be messy and error-prone; create a literal('Section 1-2a') method, which would clutter expressions; use single quote 'Section 1-2a' and patch the tree to turn all string nodes into indentifiers, but I would lose the ability to use actual strings in my expressions (porbably ok in my case).
I would like to know if expr would consider allowing backtick to enclose literal identifers, so the above
Section 1-2awould be parsed as a single identifier node. As backtick is now an illegal character I can not see backwards compatibility problems - though enabling this feature could be wrapped in an option to ensure safety. Python has deprecated backtick, so a disadvantage could be some divergence from Python-like syntax. Or possibly backtick is reserved for some future use like binary literals. Any thoughts?Beta Was this translation helpful? Give feedback.
All reactions