a C++ library of mine.

This is a discussion on a C++ library of mine. within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Originally Posted by jinhao this version is too restrictive. the property just can set/get one thing. if it gets/sets caption ...

  1. #31
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,171
    Quote Originally Posted by jinhao View Post
    this version is too restrictive. the property just can set/get one thing. if it gets/sets caption and how it gets/sets size/position and so on...
    No, it isn't.
    Instead of passing the address via the constructor, you merely pass it when defining the object within the class definition.

    Instead of:
    property<int> myproperty;
    myproperty(this, &CMyClass::mysetter, &CMyClass::mygetter)

    You do:
    property<int, &CMyClass::mysetter, &CMyClass::mygetter> myproperty;
    myproperty(this)

    Same thing. Less memory consumption.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  2. #32
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,526
    Quote Originally Posted by jinhao View Post
    this version is too restrictive. the property just can set/get one thing. if it gets/sets caption and how it gets/sets size/position and so on...
    I agree. Elysia's template is quite useless because even in the event that it works you still need to write the functions it uses underneath so 99% of the proposed benefits go away. Especially if changing state is not trivial like

    mystring.length = foo;

    How does investing in this pretty syntax save you from functions resizing string buffers and so forth? I don't even think that properties work correctly on const objects which is amateur.

    Whether or not this is more expressive is debatable to say the least. Foolish consistency is the hobgoblin of little minds. If you want properties they were correctly implemented in C#

  3. #33
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,171
    Quote Originally Posted by citizen View Post
    I agree. Elysia's template is quite useless because even in the event that it works you still need to write the functions it uses underneath so 99% of the proposed benefits go away. Especially if changing state is not trivial like

    mystring.length = foo;

    How does investing in this pretty syntax save you from functions resizing string buffers and so forth? I don't even think that properties work correctly on const objects which is amateur.
    I simply redesigned the EXISTING template which was not mine to begin with.
    And believe it or not, there's a huge amount of just set/get out there and we DO want to hide them.
    And it does get rid of point 3 & 4, which is the biggest advantage which only C#, VB & Co have enjoyed for so long.

    If you want properties they were correctly implemented in C#
    Microsoft's disgusting attempt to convert C++ to managed with a disgusting managed framework, disgusting syntax and broken or missing language features?
    No thanks.
    Equally no thanks to VB.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  4. #34
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,526
    Hey at least they did properties the right way.

  5. #35
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,171
    I'll give them thumbs up for that, at least.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  6. #36
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,383
    Quote Originally Posted by Elysia View Post
    And believe it or not, there's a huge amount of just set/get out there and we DO want to hide them.
    With what exactly?
    Public members?
    Emulating variable-like properties?
    Excluding Get and Set from function names?

    I agree with the first and do not with the other two. The second doesn't reflect C++ semantics and the third is not even a solution.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  7. #37
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Wow, all this discussion about something so small!

    Basically there's a lot of discussion over syntactic sugar, which comes at a greater price for the class writer (class having property implemented in these ways as member would require non-trivial copy constructor/operator= or be uncopyable) and some surprises for the user (because of the conversion operator the property may not always behave as expected).

    I don't find any problem with the original approach. In case of a GUI frame, setting and retrieving the caption should not be thought of as accessors to a particular data member, they encapsulate the actions this class was meant for (displaying and controlling a window). (For example, if it is a wrapper around WinAPI then it wouldn't even need a data member for the caption, since Windows stores it someplace anyway and lets me access it.)
    Last edited by anon; 09-10-2008 at 03:53 PM.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  8. #38
    Registered User
    Join Date
    Aug 2003
    Posts
    127
    Quote Originally Posted by Elysia View Post
    No, it isn't.
    Instead of passing the address via the constructor, you merely pass it when defining the object within the class definition.
    Sorry..I missed the second and third template parameter.
    Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.

  9. #39
    Registered User
    Join Date
    Aug 2003
    Posts
    127
    Quote Originally Posted by anon View Post
    Wow, all this discussion about something so small!

    Basically there's a lot of discussion over syntactic sugar, which comes at a greater price for the class writer (class having property implemented in these ways as member would require non-trivial copy constructor/operator= or be uncopyable) and some surprises for the user (because of the conversion operator the property may not always behave as expected).

    I don't find any problem with the original approach. In case of a GUI frame, setting and retrieving the caption should not be thought of as accessors to a particular data member, they encapsulate the actions this class was meant for (displaying and controlling a window). (For example, if it is a wrapper around WinAPI then it wouldn't even need a data member for the caption, since Windows stores it someplace anyway and lets me access it.)
    I totally agree with these points. I don't think the property is necessary in a C++ class, it was mentioned above.
    Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.

  10. #40
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,171
    I think we need to think outside the box of efficiency for a while.
    C++ programmers seem to be obsessed with it.
    Such a solution may be a little tricky but would give much better syntactic sugar in the end, aka to typical VB and C#, and we still run those programs, don't we?
    We don't need to cram 100&#37; speed out of the programs. It's 2008, not 1980!
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  11. #41
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    You're not willing to trade in the mediocre slowdown of VMs for greatly increased security and all the syntactic sugar of C# (of which it has heaps and heaps), but you're willing to trade in a slight inefficiency for the dubious benefit of the half-working syntactic sugar of property emulation?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  12. #42
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,171
    The problem is that I mentioned above.
    I don't like managed.
    I don't like VM.
    I don't like Interpreted, compiled or whatever.
    I don't like slow startups.
    I don't like being restricted to what I can and can't do, which .NET actually restricts.
    C# is supposed to be an "evolution," but I don't think so. So much changed to WORSE or broken.
    And the syntax is just disgusting, it ticks me off. I never have, and never will use "^" for a pointer, nor "&#37;" for a reference.
    C++ is the language I grew up with and will continue to use until a new language evolves that doesn't break its features or syntax. I'm skeptic about D, as well.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  13. #43
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    C# is supposed to be an "evolution," but I don't think so. So much changed to WORSE or broken.
    And the syntax is just disgusting, it ticks me off. I never have, and never will use "^" for a pointer, nor "&#37;" for a reference.
    You're confusing C# and C++/CLI.

    I don't like being restricted to what I can and can't do, which .NET actually restricts.
    Not really. The only thing it prevents is undefined behaviour, errors that may or may not lead to crashes. Do you think that's a worthy feature of your programs, one you can't do without?
    Unless of course you're running under restricted security, in which case it also prevents you from doing things the owner of the computer hasn't actually given you permission to do.

    I don't like Interpreted, compiled or whatever.
    So you don't like C++? It's compiled.

    I don't like managed.
    I don't like VM.
    That's just dogmatic nonsense.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  14. #44
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,171
    Quote Originally Posted by CornedBee View Post
    Not really. The only thing it prevents is undefined behaviour, errors that may or may not lead to crashes. Do you think that's a worthy feature of your programs, one you can't do without?
    Unless of course you're running under restricted security, in which case it also prevents you from doing things the owner of the computer hasn't actually given you permission to do.
    It's a trade-off. It's good, but it removes too much flexibility.

    So you don't like C++? It's compiled.
    I meant compiled on-the-fly. Like a dynamic recompiler or stuff.

    That's just dogmatic nonsense.
    Say what you want, but I don't like it and though it's not much of an argument, it's an opinion that's important to me and another reason I stay away from it.

    If Microsoft were to start building library components and enhancing C++ with safe things, then I'd probably start using them directly (they have implemented a safe C library, and I do use it when I tend to use C stuff), but not C#.
    Last edited by Elysia; 09-11-2008 at 03:29 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  15. #45
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > I meant compiled on-the-fly. Like a dynamic recompiler or stuff.
    Why not? Even when it can provide a speed advantage?

    Nothing wrong with a VM... flexibility for what!? It's rather nice to know what number representation, endianness or how big data types are the 'machine' is running, even if it is sometimes emulated.

Page 3 of 5 FirstFirst 12345 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What's an import library?
    By chiefmonkey in forum C++ Programming
    Replies: 1
    Last Post: 06-19-2009, 05:00 PM
  2. Property Set Library (PSL) - Announcement
    By vultur_gryphus in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 05-29-2008, 06:04 AM
  3. Makefile for a library
    By sirmoreno in forum Linux Programming
    Replies: 5
    Last Post: 06-04-2006, 04:52 AM
  4. very weird .h problem
    By royuco77 in forum C++ Programming
    Replies: 1
    Last Post: 09-11-2005, 07:55 AM
  5. better c string functions
    By samps005 in forum C Programming
    Replies: 8
    Last Post: 11-04-2003, 12:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21