www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - more property discussion...

reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
Continuing from another very deep thread...

On Fri, 29 Jan 2010 14:43:12 -0500, Lutger <lutger.blijdestijn gmail.com>  

 On 01/29/2010 07:01 PM, Andrei Alexandrescu wrote:
 How about  property? When you add a  property to a function it can be
 called as an assignment.  property does not touch the calling of
 no-argument functions.

 Are there any problems with that?

Such a " property is just for the writing" design will leave property adepts very unhappy, I think. Even I admit that such a rule will be very inconsistent, albeit workable. Andrei

It's not inconsistent, at most just a bit confusing on the call site. What property does is still very clear: - same syntax as fields for zero and one parameter functions - function call syntax *not* ok - mangled differently and recognizable by ide's (think gui programmming and ui design tools) and documentation tools. Probably also for metaprogramming. Additionally at the call site you can choose to drop parens for zero argument functions, author of those functions has no control over that. This feature is now orthogonal to property and may or may not end up in style guidelines. It's also one of those things a smart IDE could help you with (did the author really want this to be a property or not?) I think that solves most of the issues property was designed for.

This is slightly different than Pelle's idea in that property applied to a no-arg function requires no parentheses. Hm... what about restricting functions that allow optional parentheses to those with no arguments *and* which return void? That way they are truly orthogonal to properties. I can't say I find the parentheses or lack thereof that distracting or ambiguous on such functions. When a statement is just a symbol without any operation on it, and has no return value, it's pretty obvious that you intend to call a function. The only issue is for words that could be interpreted as properties given the right context, might they be interpreted by a reviewer as a coding error. I'm willing to live with that if it makes others happy. This allows popFront to omit the parens :) -Steve
Jan 29 2010
parent sclytrack <idiot hotmail.com> writes:
How is that message passing thing going?

C# has an attribute called [NonSerialized] and [XmlIgnore] and Java has
to mark things that are not to be serialized.

Will there be an equivalent thing for D?

I was also wondering about a syntax if you wish to automatically serialize

 DoNotSerialize  property
int number()

 DoNotSerialize  property
void number(int value)

I guess it would have to be applied to both. (sorta ugly)
Or we could "pickle" things instead.


On the Graystone's bookshelf there are several computer books. Any chance to get
TDPL on it too?
Jan 31 2010