Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Why do you put sf:: in tutorials  (Read 21585 times)

0 Members and 1 Guest are viewing this topic.

Kyle

  • Newbie
  • *
  • Posts: 13
    • MSN Messenger - kylemotherwell@hotmail.com
    • View Profile
Why do you put sf:: in tutorials
« on: September 29, 2009, 06:34:08 pm »
Why is it in functions sf:: is getting used, doesn't using namespace sf; eliminate the need for this?
Maybe you're just sitting around, reading "Guns and Ammo", masturbating in your own feces, do you just stop and go, "Wow! It is amazing how fucking crazy I really am!"?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Why do you put sf:: in tutorials
« Reply #1 on: September 29, 2009, 06:56:43 pm »
Quote
doesn't using namespace sf; eliminate the need for this?

I have a better idea. Not using a namespace at all in SFML eliminates the need for "using namespace sf".

Seriously, I leave the choice to the user. And I can't put "using namespace sf" in every piece of code of the tutorials. So at least by prefixing every class with sf:: I'me sure that I won't get hundreds of stupid posts such as "the compiler doesn't recognizes my class??!!!!" on the forum ;)

PS: I personnally never use "using namespace xxx", and I think that you shouldn't consider it obvious to do so
Laurent Gomila - SFML developer

phear-

  • Jr. Member
  • **
  • Posts: 64
    • MSN Messenger - LOApokalypse@hotmail.com
    • View Profile
    • http://gtproductions.org
Why do you put sf:: in tutorials
« Reply #2 on: September 29, 2009, 08:54:25 pm »
Whats the point of namespaces if you use the "using namespace" command? There is no point that I can think of.
Eugene Alfonso
GTP | Twitter

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Why do you put sf:: in tutorials
« Reply #3 on: September 29, 2009, 08:58:30 pm »
Quote from: "Laurent"
PS: I personnally never use "using namespace xxx", and I think that you shouldn't consider it obvious to do so
Me neither (except for some really rare cases inside a local function, for example to access an enum which is surrounded by a namespace). And I don't think avoiding this is bad practice. Most important, never write the using directive into headers because the whole namespace is emptied out in all including files.

One can also contribute reducing the global namespace pollution by not using using namespace :D
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Nothingness0x

  • Sr. Member
  • ****
  • Posts: 292
    • View Profile
Why do you put sf:: in tutorials
« Reply #4 on: December 11, 2009, 09:38:11 am »
I find it better to use "sf::" that gives personnality to SFML, besides I'm not for namespace at all, because you can do mistake if there's a same name in two differents librairies, for exemple sf::String and std::string. I personnaly use the namespace only for STD, and using "sf::" allow you to directly recognize that you are using a SFML function.  :D

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Why do you put sf:: in tutorials
« Reply #5 on: December 11, 2009, 09:45:17 am »
Quote
besides I'm not for namespace at all, because you can do mistake if there's a same name in two differents librairies, for exemple sf::String and std::string

That's exactly what namespaces are for ;)
Laurent Gomila - SFML developer

Nothingness0x

  • Sr. Member
  • ****
  • Posts: 292
    • View Profile
Why do you put sf:: in tutorials
« Reply #6 on: December 11, 2009, 10:03:25 am »
Sorry i was meaning that I'm not for writting "using namespace ..."  , just a misunderstanding  :)