Giter VIP home page Giter VIP logo

Comments (2)

alexei avatar alexei commented on August 21, 2024

The named arguments feature was (is?) an experiment. I asked myself how would you access an object's properties, then noticed it was already implemented in Python, so I did something similar.

The implementation supports keys as generic ASCII variable names. For variable names, JavaScript - like many other languages - supports special characters like devanagari or cyrillic symbols. There are a few exceptions regarding reserved keywords, but generally speaking it supports just about any letter. In addition to that, it also allows for the $ sign.
Now, regarding objects keys, I assume it supports just about everything that fits into a string, right? That includes things like ., [, ], (, ) and % that I think would totally break the parser.

But suppose we reimplement the parser so that it consumes named arguments character by character and, somehow, gets past those shortcomings. Moving forward, suppose you have a format like %(foo.bar[baz])s. How many properties does it reference: 1, 2 or 3?

That being said, currently I'm not really sure about your proposal. I think it would benefit if we added the $ character. I myself use it inside variable names and this one's easy. It might also benefit if we added support for Unicode characters - how?

Beyond that, any other character raises questions I'm not sure I want to ask, let alone answer.

from sprintf.js.

alexei avatar alexei commented on August 21, 2024

Also, I think adding them to the index access option would raise a couple of problems as well, which is why it's limited to natural numbers only.

from sprintf.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.