Why are opCall's not implicitely assignable?

Derek Parnell derek at nomail.afraid.org
Wed Sep 27 18:58:05 PDT 2006


On Wed, 27 Sep 2006 19:05:24 +0200, Ivan Senji wrote:



>> 
>>> What point?
>> 
>> Ever heard of the module scope operator
> 
> I get it now.
> 
>> or the D-style to 
>> separate an operator by one space from its operands?
> 
> And now I don't get what this means.
> 
> But I found out where the story about a "." comes from, Derek accidently 
> left if in his example, and if he or anyone else tried to compile it he 
> would get an error from the compiler about something not being a part of 
> global scope. No disaster.

True, no disaster. However I didn't leave the 'dot' in accidentally. I just
made up the syntax on the fly because I forgot that D already has a 'with'
construct. I used the 'dot' to show people reading the code which
identifiers are effected by the 'with' expression. IMHO, it is a mistake in
the current D syntax to not avoid showing this. Sure its fine for the
compiler because it can work out which identifiers are effected but for
mere humans reading the code it becomes bloody near impossible without lots
of effort.

Given ...
  with(Foo)
  {
       a = b;
       c = d;
       e = f;
  }

who'd know that it actually represented ...

       Foo.a = b;
       c = Foo.d;
       Foo.e = Foo.f;

That's why I wrote it as 

  with(Foo)
  {
       .a = b;
       c = .d;
       .e = .f;
  }

So okay, maybe I should have used a different symbol to represent the
'with' expression, but that doesn't, or shouldn't distract, from the
concept that my example was trying to express ... that we can write simpler
code that is still readable given the appropriate syntax support.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
28/09/2006 11:46:46 AM



More information about the Digitalmars-d-learn mailing list