- Data structure in C++ or C - 3 Updates
- Christianity is not a religion - 3 Updates
- About PascalABC.NET - 1 Update
- And here is another project called PascalABC.NET - 1 Update
- Modern Object pascal is one of the best! - 1 Update
- OOP is the new GOTO - 4 Updates
- Question on app safety - 1 Update
- Writing a wrapper class for a local object to pass to a function - 3 Updates
- Open letter to Mr Stroustrup - 4 Updates
- High horse - 1 Update
Rosario19 <Ros@invalid.invalid>: Jun 22 08:42PM +0200 On Wed, 20 Jun 2018 12:13:20 -0500, Robert Wessel wrote: >Some tree structures can handle duplicate keys, others can't, but even >the ones that can't, can be adapted by adding a sequence number to >each element, and using that as the low part of the key. i read all this code on "red-black" binary tree but it seems to me too much conplex... even normal code for tree it seems to me too much complex... i like normal binary tree, that gets its input in random form i has to have one limitation, it is easier than i write the right code alone, [better if read something general and not particular] better than copy or adact some code seen in one book |
red floyd <dont.bother@its.invalid>: Jun 22 02:09PM -0700 On 6/22/2018 11:42 AM, Rosario19 wrote: > i has to have one limitation, it is easier than i write the right code > alone, [better if read something general and not particular] better > than copy or adact some code seen in one book Straight up binary trees have an O(N) worst case. Try creating one with an ordered sequence (e.g. 1, 2, 3, 4, 5, 6, 7, ...). You wind up with a linked list. |
Vir Campestris <vir.campestris@invalid.invalid>: Jun 22 11:15PM +0100 On 22/06/2018 19:42, Rosario19 wrote: > i read all this code on "red-black" binary tree > but it seems to me too much conplex... > even normal code for tree it seems to me too much complex... I read what set and friends do, and don't worry about the implementation. Using them is easy. Perhaps one day I'll be writing a new STL library - but it seems pretty unlikely. Until that day I won't need to know how it works, only how it behaves. Which is O(log N). (I did have to wrote a hashmap ~5 years back. Because it needed to be in C - which of course doesn't have STL) Andy |
gazelle@shell.xmission.com (Kenny McCormack): Jun 22 07:58PM In article <dd6cd508-fe36-4aef-81e1-ebce9d4f098f@googlegroups.com>, >For some, a religion is all Christianity will ever be. They miss it. >Religion says, "If you do this, then you will achieve that." What >Christianity is is this: "You cannot achieve Heaven on your own Shouldn't you really be calling this thing "Rickianity" ? Since what you are selling here bears no resemblance to what just about every other person on the planet means (i.e., refers to) then they use the word "Christianity". I.e., you're just redefining words. It is as if I told you that a cat barks, and then went on to explain that what I mean by "cat" maps to what every other person on the planet refers to as a "dog". So, from here on in, please refer to your product as "Rickianity", and everyone (yes, even you!) will be a lot happier. -- No puppet. No puppet. You're a puppet. |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Jun 22 04:18PM -0400 On 6/22/2018 3:58 PM, Kenny McCormack wrote: > every other person on the planet refers to as a "dog". > So, from here on in, please refer to your product as "Rickianity", and > everyone (yes, even you!) will be a lot happier. Have you ever read these verses: https://www.biblegateway.com/passage/?search=Matthew+7%3A21-23&version=KJV 21 Not every one that saith unto me, Lord, Lord, shall enter into the kingdom of heaven; but he that doeth the will of my Father which is in heaven. 22 Many will say to me in that day, Lord, Lord, have we not prophesied in thy name? and in thy name have cast out devils? and in thy name done many wonderful works? 23 And then will I profess unto them, I never knew you: depart from me, ye that work iniquity. In scripture, they didn't have bold font type, so they use repetition to indicate significance or emphasis. They say that God is "holy, holy, holy," for example. It's repeated three times to stress just how holy God is. If it were in our modern writing, it would not only be bold, but probably italicized, underlined, and in a font size that is two or three up from the rest of the nearby text. It may even have a different color background for highlighting. Here we see Jesus saying, "Not everyone who says to me, Lord, Lord..." This is Jesus effectively saying, "Not everyone who emphatically said I was their Lord and Savior will be saved. Not everyone who lived their life purportedly for me will be saved, but only those who do the will of my Father who is in Heaven." What is the Father's will? To lead people to His Son so they can be saved. To live a holy life so that we can be servants of God in this world, pursuing Him in spirit and in truth, denying our fleshly lusts, and being at the constant, ready position to move when His spirit calls us from within. The reason you see an impotent church affecting NOTHING in this world, being just like the world, doing the same things the world does, is because they are not following Jesus Christ. They have a weak religion and they are yet dead in their sin. My message is simple, Kenny: You have sin. Your sin will condemn your eternal soul to Hell. You need to be forgiven to be saved. Jesus went to the cross so you could be forgiven. He wants to forgive you. He asks you to ask Him to forgive you so He can forgive you. He sends out people like me all over this world to point you to Him. Only those people who hear His call and answer it by repenting of their sin and asking forgiveness from Jesus personally will be saved. And once again, Christianity is not a religion. It is a personal, ongoing, daily, unending relationship with Jesus Christ. It's from the inside out and it changes everything about you. That's the born again nature. Religion is merely learned lessons from the outside in. It has no saving power, even though it has the outward appearance of being similar to the true saved state. -- Rick C. Hodgin |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Jun 22 03:04PM -0700 On Friday, June 22, 2018 at 3:58:25 PM UTC-4, Kenny McCormack wrote: > No puppet. > No puppet. > You're a puppet. Kenny, do you even care about the truth? If you do, you'd listen to men like this and hear what He has to teach about being alive in this world, what it means to have a real focus and purpose upon Christ as we're supposed to be: https://www.youtube.com/watch?v=AP6cc2aBecE If you wanted to the pursue the truth, you'd learn about the invisible spiritual war we're all facing (yourself included). You'd learn about how the forces the Bible teaches us about really are working against us interpersonally, in our society, in and about everything we're a part of as living, breathing creations of God: https://www.youtube.com/watch?v=UDVWvOQvlK8 If you want to know the truth ... then seek it. It won't be me who teaches it to you. It can't be taught. It can only be identified, and that's something only the spirit nature that comes when you come to Jesus repenting and asking forgiveness, and when He takes your sin away you are born again in that self- same instant. Only then can you know the truth. But God is faithful, Kenny, even when we are not. If you seek the truth, He will know you are seeking it, and He will make it possible for you to find it. I LOVE YOU, KENNY! It's why I teach you the truth. Please do not think it's anything other than what I'm telling you. It does yourself a tremendous disservice when you summarily gloss over things without investigating them. The Bible says it this way: https://www.biblegateway.com/passage/?search=Proverbs+18%3A13&version=KJV 13 He that answereth a matter before he heareth it, it is folly and shame unto him. Do not live in shame. Search this matter out for yourself. See for yourself if what I teach is true. Do not compare the teachings to the impotent teachings of the worldly Christian religion. Seek to know Jesus Christ Himself and become a true born again Christian. Then you'll know why I say it's not religion. -- Rick C. Hodgin |
Sky89 <Sky89@sky68.com>: Jun 22 08:45PM -0400 Hello.. About PascalABC.NET here: http://pascalabc.net/en/ I think i will not port my projects to PascalABC.NET because its documentation is in russian only, so it lacks documentation in english, so i will stay with modern Object Pascal of Delphi and FreePascal compilers. This was my last post about modern Object Pascal here on this C++ forum Thank you, Amine Moulay Ramdane. |
Sky89 <Sky89@sky68.com>: Jun 22 08:16PM -0400 Hello.. I am also working with modern Object Pascal of Delphi and FreePascal compilers.. And here is another project called PascalABC.NET that is also "modern" Object Pascal, i think i will port many of my projects to it too, look at it here: http://pascalabc.net/en/ Thank you, Amine Moulay Ramdane. |
Sky89 <Sky89@sky68.com>: Jun 22 08:05PM -0400 Hello, Modern Object pascal is one of the best! I am also working with it by using Delphi and FreePascal.. photoshop 1stS releases were in "modern" Object Pascal, more than 100 000 lines, easy to maintain (2 only programmers), look at it here: https://github.com/amix/photoshop Thank you, Amine Moulay Ramdane. |
Tim Rentsch <txr@alumni.caltech.edu>: Jun 21 01:00PM -0700 Tiib writes: > Stroustrup did somewhere explain that 'this' is a reference that uses > pointer's syntax because reference wasn't yet invented when 'this' was > introduced into language. The distinction between a pointer and a reference is not important to what I was saying. |
Tim Rentsch <txr@alumni.caltech.edu>: Jun 21 01:11PM -0700 >> that 'this' is a pointer rather than a value. > I quite often use object-oriented programming, sometimes with virtual > functions and all, without handling objects by pointer, but by value. I think you are confused. Virtual functions don't work if the receiver of a message send is a value ratther than through a pointer/referece. > 'this' might act similarly to a const pointer, but it's rare to even > need to refer to it explicitly. Explicitness is irrelevant to my comment. > Even when you do, it can be the only exception. Fine but the exception is crucial! The message recipient being referred to by pointer or reference is what makes the receiver an object. |
Tim Rentsch <txr@alumni.caltech.edu>: Jun 21 01:14PM -0700 > r: (final executed basic block: state := 0) > esac > od Do you have a point here? If your point is that arbitrary control flow can be simulated by a loop and a case statement, that is true, and also obvious. But it is quite beside the point of my comment. Do you see why? |
Rosario19 <Ros@invalid.invalid>: Jun 22 08:23PM +0200 On Thu, 21 Jun 2018 13:11:17 -0700, Tim Rentsch wrote: >>> that 'this' is a pointer rather than a value. >> I quite often use object-oriented programming, sometimes with virtual >> functions and all, without handling objects by pointer, but by value. someone can to clear this? i don't know even what "virtual" means, nor interst me; but i'm interested in the question on objects... in the few seems to me to be the situation one obj has to be a space of memory one address start one address end and all to code and decode it so all the objs has to have one pointer to them or one reference so when i pass one number to one function that use reference example for example we have int f(int& a){...} f(23) this is not ok 23 is not one obj is just one immediate i pass to the function (even if 23 is push in the stack it is one obj but the compiler not think so) so the compiler it seems has need of create one obj, fill it with value 23 and pass its address in the function in a way i not see "f(23)" means, "{Int t(23); f(t);}" ----------------------------- int t=23; f(t) ok pass one obj to f |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Jun 22 09:48AM -0700 On Thursday, June 21, 2018 at 5:15:09 PM UTC-4, Mr Flibble wrote: > > If any of you were truly wrong about your beliefs in how the universe > > formed, or how we got here ... would you want to know? > Speed of light mate. If you are going to continue to espouse this statement, at least do it right. It should be, "Speed of light, mate." I urge you to read this part: There's more to the truth of who Jesus is than your gainsaying reply. If you ever want to seek the truth, Leigh, you will find it. All who seek the truth do. The rest will perish in their arrogance. /IF/ you were wrong, Leigh, /IF/ you were wrong ... would you want to know? That's a yes or no question only you can answer. You will know the answer in your heart. -- Rick C. Hodgin |
bitrex <user@example.net>: Jun 21 07:41PM -0400 On 06/21/2018 02:10 AM, Öö Tiib wrote: > you have to work with in that "non-template function" have to make > that underlying Foo rather opaque since EventDataBase has to work > well when there are no Foo (like it is EventData<Moo>). Surely, I'll post a sketch of solution...there's a lot of stuff I could do rather than feed wrappers to functions taking base class pointers like say std::functional or std::any if I were on a desktop environment but this is for an embedded environment where I essentially just have the stock C++11 features and not a lot more, and the codebase I'm working with is pre-modern C++. I don't see any way to avoid an explicit compile-time template parameterization or cast so the base class pointer "knows" WTF it's supposed to be handing off to the callee to work with but that's okay in this case. The full assembly output from e.g. MIPS64 gcc 5.4 -std=c++11 -O1 is here: <https://pastebin.com/PAVvfqM4> #include <iostream> template <typename DataType> class EventData; class EventDataBase { public: virtual ~EventDataBase() = default; template <typename DataType> DataType data() const { auto pkg_ptr = static_cast<const EventData<DataType>*>(this); return static_cast<DataType>(*pkg_ptr ); } protected: EventDataBase() = default; private: virtual const EventDataBase* data_() const = 0; }; template <typename DataType, template <typename> class EventData> class EventDataCRTP : public EventDataBase { public: static EventData<DataType> create_event_data(const DataType& data) { return EventData<DataType>::create_event_data_(data); } }; template <typename DataType> class EventData : public EventDataCRTP<DataType, EventData> { friend class EventDataCRTP<DataType, EventData>; public: //don't want or need copying/copy assignment of wrapper class in //callee it's holding a reference to obj on stack EventData() = delete; EventData(const EventData&) = delete; EventData(EventData&&) = default; EventData& operator=(const EventData&) = delete; EventData& operator=(EventData&&) = default; explicit operator const DataType&() const { return message_data_; } protected: static EventData<DataType> create_event_data_(const DataType& data) { //do something here if required return EventData<DataType>{data}; } private: EventData(const DataType& data) : message_data_{data} {} const EventDataBase* data_() const override { return this; } private: const DataType& message_data_; }; void do_stuff(const EventDataBase* data) { //use it here std::cout << data->data<int>() << std::endl; } int main() { int foo = 1; //make a wrapper here auto bar = EventData<int>::create_event_data(foo); do_stuff(&bar); } |
"Öö Tiib" <ootiib@hot.ee>: Jun 21 10:55PM -0700 On Friday, 22 June 2018 02:41:29 UTC+3, bitrex wrote: > auto bar = EventData<int>::create_event_data(foo); > do_stuff(&bar); > } Your example is not motivating since your do_stuff assumes that the data is int, seemingly rendering all the code pointless. So I may be wrong but it looks likely that you want to have something like std::variant. |
bitrex <user@example.net>: Jun 22 11:40AM -0400 On 06/22/2018 01:55 AM, Öö Tiib wrote: > data is int, seemingly rendering all the code pointless. So I may > be wrong but it looks likely that you want to have something like > std::variant. The issue I face isn't so much that the callee function itself requires type-erasure and needs to itself be able to work with a variety of types. It's more along the lines that the callee is used as a template argument to a class template taking a particular type of member function pointer to use as a callback, for example: template <typename SomeHandlerClass, void (SomeHandlerClass::*Func)(const EventDataBase*)> class Bar { ... etc. and the callee is defined as something like aHandlerClass::do_stuff(const EventDataBase* data) "do_stuff" is then passed as a template parameter for the construction of Bar. I guess I could further parameterize Bar with a third template argument so on construction I could also make specific the argument of the member function pointer Func takes a template parameter as well. But gosh it seems like an unnecessary complication as the callee do_stuff "knows" fine what type it's supposed to be working with and the conversion to the appropriate data type can be done perfectly well at compile time with a cast or template over there instead. I'm kinda memory-limited so I'd prefer not to blow up the variety of template-types that get generated. |
"Öö Tiib" <ootiib@hot.ee>: Jun 21 10:14PM -0700 On Friday, 22 June 2018 00:49:34 UTC+3, jacobnavia wrote: > If there is no operator[] that should be a compile time error of course. > But what are you doing when incrementing each element of a set? > A set... maybe you just mixed up something? Yes, good catch! Set elements aren't mutable so can't increment. Others like std::list also do not have []. > instead of > v.size() > ???? The raw array does not have methods. It decays to pointer and so works with operator [] of pointer. Therefore in templates (or when generating code in some other way) std::size works bit better. > optimizations, and other things. > You can at run time choose some algorithm for small matrices that > doesn't scale but is great for small data sets using the size information. That is implemented in std::array. It has efficiency of raw array but usage of library container. The a.size() is compile time constant. |
"Öö Tiib" <ootiib@hot.ee>: Jun 21 10:38PM -0700 On Thursday, 21 June 2018 13:25:18 UTC+3, Manfred wrote: > for(V::iterator it = v.begin(); it.end() != it; ++it) ++(*it); > (V being the type of the container, and avoiding 'auto' just to stick > with C++98) Yes. Also because of lack of lambdas the C++98 algorithms were harder to use and so C++98 code was often full of those for's. > So, together with improved compactness, IMHO some piece of clarity is > also lost. I'm not saying it is not worth it, just that it doesn't come > for free. I have noticed that the (unimportant at that point) details may damage clarity. For example exceptions are better for error handling than error codes because those let us to have constructors and operators that can fail. Handling of the failed cases is moved to catch block (or down the call stack) and so the clarity of code that deals with normal case is improved. |
Bo Persson <bop@gmb.dk>: Jun 22 11:08AM +0200 On 2018-06-22 00:12, jacobnavia wrote: > The typing mistake is easily fixed, in most cases. And please consider: > for (int& elemnt : container) ++element; > is just as wrong... Yes, this will likely cause a compile error. The problem with i and j in nested loops is that the code will often compile, even if you mix them up badly. for (int i = 0; i < matrix.size(); i++) for (int j = 0; j <= matrix[j].size(); i++) // OOPS * 3! cout << matrix[i][j]; vs for (auto& row : matrix) for (auto col& : row) cout << col; Which one is easiest to learn? And easiest to get right? Bo Persson |
Bo Persson <bop@gmb.dk>: Jun 22 11:11AM +0200 On 2018-06-22 11:08, Bo Persson wrote: > for (auto col& : row) > cout << col; > Which one is easiest to learn? And easiest to get right? And this does give you a compile error when you place the & wrong. Still not perfectly simple, apparently :-) |
Tim Rentsch <txr@alumni.caltech.edu>: Jun 21 01:18PM -0700 >> FWIW that is how the statement struck me when I read your >> posting. Just fyi. > It matched to tone of the OP... Responding in kind serves to legitimize his comment. Better to answer in a calm and rational way, and very plainly not overstate the case. Otherwise you are just proving his point. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment