Why are opCall's not implicitely assignable?
Stewart Gordon
smjg_1998 at yahoo.com
Mon Sep 25 07:29:04 PDT 2006
Karen Lanrap wrote:
<snip>
> Now I want to assign colors to the colorable parts
>
> Car car;
> void main()
> {
> car= new Car;
> car.roof= COLOR.LIGHTBLUE;
> seats[0]= COLOR.DARKBLUE;
> seats[1]= COLOR.RED
> // ...
>
> But you say that I am not allowed to do this, because the colorable
> parts are no properties of the car?
Correct. Such notation would mean setting the roof itself or the seats
themselves, not their respective colours. The colour is not the
component; it is merely a property of each component.
> <snip>
> Why do I have to write
>
> COLOR col= seats[0].color;
>
> when it would suffice to write:
>
> COLOR col= seats[0];
>
> because of appropriate opCalls?
Two reasons. Firstly, it wouldn't make sense - seats[0] is already a
seat, it cannot be a colour at the same time. Secondly, there's nothing
appropriate about using opCall for something like this, even if it did work.
Stewart.
--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:-@ C++@ a->--- UB@ P+ L E@ W++@ N+++ o K-@ w++@ O? M V? PS-
PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y
------END GEEK CODE BLOCK------
My e-mail is valid but not my primary mailbox. Please keep replies on
the 'group where everyone may benefit.
More information about the Digitalmars-d-learn
mailing list