Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Allegro Naming Conventions

This thread is locked; no one can reply to it. rss feed Print
 1   2   3 
Allegro Naming Conventions
Chris Katko
Member #1,881
January 2002
avatar

I was reading through the discussion of the api-style (draft two) for Allegro 5. And if I'm correct, Allegro 5 will be prefix functions with al_, Al_ or Al. I personally prefere the first, but that's beyond the scope of this thread.

The problem I see with this, is that OpenAL already does this. Exactly. So this could create some confusion couldn't it?

OpenAL prefixes functions with "al" and constants with AL_. What happens if Allegro does the same and someone uses both libraries together? (Which is not as far-fetched as you would think.)

What's your thoughts on this?

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Marcello
Member #1,860
January 2002
avatar

namespaces

Chris Katko
Member #1,881
January 2002
avatar

It's pointed out in the article that Allegro 5 will have no C++ (unless I missed something) and will therefor have no namespaces.

[edit]

Took me a sec to find it again (it's quite big).

Quote:

Allegro 4 and previous include little C++ code, but this is very probably going to be dropped in the next version).

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Marcello
Member #1,860
January 2002
avatar

That's a pretty old file, have you been reading the alleg5 list? From what I recall there was a push to more c++ in version 5.

As for namespaces, I was joking. Obviously.

Marcello

Thomas Fjellstrom
Member #476
June 2000
avatar

There will only be a problem if OpenAL and Allegro have an identically named identifier. No problems otherwise.

Oh, and one of the UWIP's (Uber Work In Progress) for Allegro 5 uses C++ in the core for the driver system. but exposes a C and C++ compatable API to the user.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Chris Katko
Member #1,881
January 2002
avatar

The Alleg5 mailing list? I forgot about that. I'm talking about the documents in the "Allegro's future proposals" section.

Most aren't that old.

[edit] 1 post hit while I was writing.

TF: I'm mostly talking about readability (which the document was about).

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Bob
Free Market Evangelist
September 2000
avatar

The C++ thing is for internals only. The Allegro API will remain C only.

Yes, we do know prefixes still have issues: OpenAL uses the same ones, and so do several other libraries. It's not something we can really avoid - there simply is no way to isolate expoerted C code.

(edit: s/OpenGL/OpenAL/)

--
- Bob
[ -- All my signature links are 404 -- ]

CGamesPlay
Member #2,559
July 2002
avatar

"C only" <-- Really? The C++ won't be exposed at all?

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

A J
Member #3,025
December 2002
avatar

all my wisdom tells me C++ internal and C extern is a REALISTIC WORKABLE SOLUTION.

those 3 words are VERY important.

as for AL_ i suggest alg_ much better chance of it avoiding name conflicts.

___________________________
The more you talk, the more AJ is right. - ML

Chris Katko
Member #1,881
January 2002
avatar

Wouldn't "all_" work?

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Bob
Free Market Evangelist
September 2000
avatar

Just to be sure, it should be allegro_game_programming_library_. No confusion could possibly arise from such a prefix.

--
- Bob
[ -- All my signature links are 404 -- ]

23yrold3yrold
Member #1,134
March 2001
avatar

OpenAL and Allegro may both use the "al" prefix, but the function naming conventions beyond that are different (mixed caps vs. underscore mania). I wouldn't sweat it ...

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Chris Katko
Member #1,881
January 2002
avatar

Bob! Let's just port Allegro to C# and only support C# that way, EVERYONE is happy! Namespaces! Circular dependances! It's heaven! ;D

Back to sanity:

I don't think it'll matter much either 23, but to be sure, I thought I'd ask here, just incase is hasn't been thought about.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Evert
Member #794
November 2000
avatar

I've been thinking about this... wouldn't it be possible to encapsulate the contents of allegro.h in something like

namespace allegro {

extern "C" {

// stuff

}

}

depending on __cplusplus being defined and some preprocessor flag to indicate we Allegro wrapped up in a namespace (making it the default will break older code)? Alternatively, one could make a seperate header file that does this.

If it works at all (and due to the way Allegro mangles some things through #defines and inline functions, I'm not at all sure that it would) this would solve the namespace issue only for C++, not for C, but it has the advantage that it could be done now and quickly. And some solution is probably better than none.

MindCode
Member #2,031
March 2002
avatar

I still don't understand the aversion to C++ to begin with. Clearly people who use C ONLY won't be able to use C++ code. But who is so hardcore C that they don't use C++? Is there really anyone out there who refuses to use C++? (which has been standardized as of 2 years ago) If these strange and illusive people are out there maybe someone should slap them back to reality.

______________________________________
Frag The Planet

Chris Katko
Member #1,881
January 2002
avatar

Well, C is "faster" then C++. Which is actually true, but the fact that John Carmack has given C up for Doom 3 should say something about the overhead being not a real issue.

I think nowadays, it's just a preferance issue, except on embedded systems (not consoles, actual embedded systems).

Though I wish I could get some of those circular dependances (a C# feature) in C++... :(

[edit] Was that directed at me, Matt?

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Matthew Leverton
Supreme Loser
January 1999
avatar

I prefer to use C over C++ for any project that I'm going to be doing solo. If I wanted C++ Allegro, I could create a wrapper of sorts around any features that I really cared to have as OOP.

You are shallow minded if you think C++ is always better than C. There's more out there than just high-end PCs, and there's more than just large scale projects that benefit from OOP.

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

But who is so hardcore C that they don't use C++?

I've said it many times. but its not a "hardcore" thing. I prefer C, as I over engineer when coding in C++, designing an API takes me way too long in C++, so I do C, and C works perfectly fine. I don't need any of the C++ features. (some of them even slow me down...)

Quote:

If these strange and illusive people are out there maybe someone should slap them back to reality.

Can I slap you? Please? No really. Don't assume things about people, it tends not to be too accurate.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

kronoman
Member #2,911
November 2002
avatar

Quote:

The C++ thing is for internals only.

Question:
The, a C++ compiler will be required to compile Allegro, even if I only want to use it for C coding (and thus, I don't have the C++ stuff) ?

I mean, for example, If I only have installed GCC, but not GPP, it will still be possible to compile Allegro?

Bob
Free Market Evangelist
September 2000
avatar

Quote:

mean, for example, If I only have installed GCC, but not GPP, it will still be possible to compile Allegro?

Nope, you will require a C++ compiler.

Btw, none of this is set in stone. We're just experimenting with some things. For example, my version of the code only uses C, and implements Java-style dynamic binding. Peter's C++ version requires that add-ons and user code be compiled with a common ABI to share Allegro internals.

--
- Bob
[ -- All my signature links are 404 -- ]

Evert
Member #794
November 2000
avatar

Quote:

But who is so hardcore C that they don't use C++?

I hardly use C++ at all. The only reason I'm writing C++ code at the moment is because I had a good use for object inheritance and constructor/destructor functions.
I still prefer to use C or C-like constructions for a lot of things though.

Quote:

Is there really anyone out there who refuses to use C++? (which has been standardized as of 2 years ago)

It being standardized is not an issue. FORTRAN has been standardized over twenty-five years ago, and I don't actively use that either.

Trezker
Member #1,739
December 2001
avatar

I think we should leave the c coders alone.
IMO allegro works fine without any c++ interface.

I think it would be stupid to make separate versions to please both sides.

Matthew: Don't forget that OOP is available in c too, struct, DIALOG object...
It's just that in c you need more guns to blow your leg off.

A J
Member #3,025
December 2002
avatar

anyway, what can C++ do that C cant ?

___________________________
The more you talk, the more AJ is right. - ML

Evert
Member #794
November 2000
avatar

Quote:

anyway, what can C++ do that C cant ?

In a sense, nothing, in another sense, a lot.

C and C++ both compile to machine code, so either language can do what the other does from the machine's point of view. C++, however, offers functionality to the programmer that C does not: operator overloading, namespaces, polymorphism.

Trezker
Member #1,739
December 2001
avatar

C++ is offering some higher level coding, what you use depends on what suits you best.
Some people don't understand some of this stuff, and others just don't like the way it's done.

 1   2   3 


Go to: