Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Coffee corner » c++ standard read-only property flag would be handy
c++ standard read-only property flag would be handy [message #49066] Tue, 12 December 2017 11:59 Go to next message
luoganda is currently offline  luoganda
Messages: 153
Registered: November 2016
Experienced Member
for c/c++ language usually set/get are needed for properties,
using public_read section or flag would be useful for
properties, so there are not unneded code, eg:
class Class{
  public:
  //accessed and modifiable by any
  int someProp;
  
  //this would be non-modifiable in outer usage
  public_read:
  int somePropX;

  //or
  int public_read somePropX;
  //or
  public_read int somePropX;
  //or something...
};


for compilers that would not implement this,
just "unsafe" public: would be used instead.
Re: c++ standard read-only property flag would be handy [message #49067 is a reply to message #49066] Wed, 13 December 2017 09:21 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
luoganda wrote on Tue, 12 December 2017 11:59
for c/c++ language usually set/get are needed for properties,
using public_read section or flag would be useful for
properties, so there are not unneded code, eg:
class Class{
  public:
  //accessed and modifiable by any
  int someProp;
  
  //this would be non-modifiable in outer usage
  public_read:
  int somePropX;

  //or
  int public_read somePropX;
  //or
  public_read int somePropX;
  //or something...
};


for compilers that would not implement this,
just "unsafe" public: would be used instead.


IDK, people are having these various ideas about properties, but I do not understand why. Is it really so hard to write () ?

Also, with (writable) properties, one can do things like

a.ink = White;
a.font = Arial;


which IMO is really verbose and inconvenient compared to "U++ chained modifiers" style

a.Ink(White()).SetFont(Arial());
Re: c++ standard read-only property flag would be handy [message #49068 is a reply to message #49066] Wed, 13 December 2017 12:44 Go to previous messageGo to next message
luoganda is currently offline  luoganda
Messages: 153
Registered: November 2016
Experienced Member
Bar::Item(orIt'sDerivates) is a good example why.
ToolButton is one such derivate.

There is no way to read properties, only Set... are there like Text(), but no Get(),
unless someone 1)subclasses it or 2)duplicate data in advance <=both is unneded

If this c++ flags were available, there would be no hokus pokus to
get those values now(noNeedToWrite Get...) and worying if both set/get is implemented,
because they would already be available by design.

+ you get direct access to it, no need to worry if
setter/getter is written as by val/ref ,like ...& Get(...) and Set(...&) to access it byRef

[Updated on: Wed, 13 December 2017 13:20]

Report message to a moderator

Re: c++ standard read-only property flag would be handy [message #49069 is a reply to message #49068] Wed, 13 December 2017 13:54 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
Bar::Item is not really a good example: there are no member variables in it...
Re: c++ standard read-only property flag would be handy [message #49071 is a reply to message #49066] Wed, 13 December 2017 18:57 Go to previous messageGo to next message
luoganda is currently offline  luoganda
Messages: 153
Registered: November 2016
Experienced Member
yeah, i know,
post was re-edited a few moments later...
Re: c++ standard read-only property flag would be handy [message #49072 is a reply to message #49071] Wed, 13 December 2017 19:06 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
Well, but we are not in control of C++ standard anyway... Smile
Re: c++ standard read-only property flag would be handy [message #49081 is a reply to message #49066] Fri, 15 December 2017 15:15 Go to previous message
luoganda is currently offline  luoganda
Messages: 153
Registered: November 2016
Experienced Member
yeah, i know that too...
Previous Topic: OCR library (Tesseract?)
Next Topic: some good audio library?
Goto Forum:
  


Current Time: Tue Aug 20 14:03:27 CEST 2019

Total time taken to generate the page: 0.01141 seconds