Coder Social home page Coder Social logo

Comments (3)

eyalroz avatar eyalroz commented on July 20, 2024

Can you elaborate on the sense in which you find underscore use excessive? Do you mean the use of underscores at the end of function names?

I'm generally against abbreviations unless they're really necessary. I don't want the reader of the code to have to keep a bigger "dictionary" in their heads, decyphering shorthands and acronyms as they go, and wondering whether they actually mean the same thing as the long version of the name.

'prn' is a common abbreviation of 'print',

No it isn't... I've never seen any library using "prn" instead of "print". Maybe you mean prnf()? Even that is a bit fishy. If I see it, I would assume it might be somewhat different to printf().

Actually, it's bad enough that we have printf() rather than print_formatted() or formatted_print()...

It would make it obvious in applications which use prnf(), that they are not using the standard implementation.

  1. And you believe it is not obvious that printf_() is not the standard implementation?
  2. But it would make it non-obvious that they're using something that's compatible with the standard implementation.

printf() could still be overridden by the prnf() implementation, using #defines as it is now.

You can also write prnf() as a wrapper function around vprintf_() if you like.

from printf.

mickjc750 avatar mickjc750 commented on July 20, 2024

from printf.

eyalroz avatar eyalroz commented on July 20, 2024

My rationale for printf_() is: "This is just like printf(), but not printf() from the standard library."

The use of a trailing underscore for "just like but not quite" is common in, well, C++, e.g. when you have a member variable and you want to take an initializer with essentially the same name. So you typically named one of them foo_ and the other foo, or vice versa.

I'm not buying into prnf()... but if someone were to suggest a consistent alternative naming scheme for all functions with a rationale, I would seriously consider it.

Regardless - perhaps we can add an entry to the README about how to get whichever name you like with a wrapper.

from printf.

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.