Jump to content
  • Advertisement
Sign in to follow this  
The C modest god

Adding a feature to CPP

This topic is 4281 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I thought it would be nice if you could define your own recursive method. It will be just like a dtr. Lets call this methos Recur Every class will have the default Recur which will only call the Recur of all its class members. You will able to overide this method in every specific class. Its a great feature that could enhance CPP. What do you think?

Share this post


Link to post
Share on other sites
Advertisement
I think what you're asking is if you can modify how classes are defined in C++, i.e. add this "Recur" method to the standard interface of a class much like every class can (and should) define a constructor/destructor, this "Recur" method would be another addition to the way we commonly define classes.

Now, this is a big assumption because I really am not sure what you're asking, but if this is what you're asking then I'll have to tell you that you can't really change the way classes are understood to be, or interpreted in C++, but with _very_ good reason. The language was given much thought when it was developed and has fairly standard procedures for adding new features AFAIK.

To me though, and this is partly due to the fact I really don't know what you're talking about, this doesn't really sound like a necessary or even good addition to the language. I have never found the need for such an addition to the way classes work in C++, and as of yet you've failed to convince me otherwise (again, specifically because what you're saying is fairly unclear).

Care to explain a little more?

Share this post


Link to post
Share on other sites
What is the standard procedure to add such a feature?

Well, I am making my own memory management.
CPP does not have reasonable support or any language support to multi threading, so how can you say nothing is missing in this language?

The thing is, I want to "cunurrently" relase several heap allocated objects.
These objects may have reference pointers to each other, maybe even in a circle.
So I need to first release the references pointers before actually deleteing the data, so I wont have a dangling reference or something like this.
I could simply right for every class a method that will call all the sub classes methods of the same method that its purpose is to release there reference pointers.
But I would rather have some sort of a recursive method like the dstr.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by The C modest god
What is the standard procedure to add such a feature?

Well, I am making my own memory management.
CPP does not have reasonable support or any language support to multi threading, so how can you say nothing is missing in this language?

The thing is, I want to "cunurrently" relase several heap allocated objects.
These objects may have reference pointers to each other, maybe even in a circle.
So I need to first release the references pointers before actually deleteing the data, so I wont have a dangling reference or something like this.
I could simply right for every class a method that will call all the sub classes methods of the same method that its purpose is to release there reference pointers.
But I would rather have some sort of a recursive method like the dstr.


in case that you should actually consider suggesting whatever you are describing here for the upcoming version of C++0x, you might also want to seriously consider reading up on grammar and spelling, as you might then have better chances to be taken seriously then.

Also, the proper "procedure" to discuss potential language enhancements for C++, is to discuss your ideas in comp.lang.c++ (usenet newsgroup). Un general, it is a good idea to provide real life case examples for why your suggestion might be useful.

On the other hand, suggestions for language enhancements are usually only taken seriously if they come from people who are INHERENTLY familiar with the language itself, you-as someone who has obviously just started to learn it- might rather want to get more familiar with it, before riskiing to be flamed for making a totally incomprehensible and possibly even idiotic "suggestion".


Share this post


Link to post
Share on other sites
Quote:
Original post by The C modest god
Is there a book on the internal of CPP?
Like all the VTables?
Perhaps resources on the internet?


No, because the internal of C++ (ie its implementation) is compiler dependant. The compiler vendor decides how it deals with such issue, and there is no standard that describe them. A vendor may find a way to represent vtables that doesn't add any overhead to the class, while another one might decide to add a hidden pointer in the class.

Going back to your original question (and when I say original, I really mean original), what makes you think that such feature is useful? How would it be used? Does an int have a "default Recur"? I still don't get your point (and even if I understood you, I'll tell you that Recur is really a poor name). Can you detail this? (not by throwing 3 words in a post: try to be more formal).

BTW, multi-threading support is not done by the language - it is done by a library so you can use it if you want, and forget it if you don't want it (adding 0 overhead in this case). This is the philosophy of the language: you pay for what you use.

Regards,

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!