@property needed or not needed?

Era Scarecrow rtcvb32 at yahoo.com
Mon Nov 19 10:58:19 PST 2012


On Monday, 19 November 2012 at 18:21:55 UTC, Mehrdad wrote:
> Why don't we just outright disallow expression-statements?
>
> After all,
>
>      2 + 3;
>
> should not be a valid statement, and so
>
>      foo.property;
>
> should not be, either.

  Hmmm I would say if it's const/immutable and pure then it would 
be an error (Side effects considered after all), otherwise 
popFront may not work (it is a property I believe...right?).

  So let's assume I make some struct to call the PC Speaker (for 
whatever reason) then the following would break.

struct PCSpeaker {
   int dingsCalled;
   void ding() @property {
     dingsCalled++;
     //some low level calls
   }
}

  However if it was...

   void ding() @property const pure

  We know there's no side effects (and it can't modify the 
struct), which then 'ding' could be an error on it's own 
(Although without a return value that would make the signature 
completely useless).


More information about the Digitalmars-d mailing list