Why are opCall's not implicitely assignable?

Stewart Gordon smjg_1998 at yahoo.com
Thu Sep 21 16:43:49 PDT 2006


Karen Lanrap wrote:
> Stewart Gordon wrote:
> 
>> If it did, then how would you
>> assign object references of classes that have opCall at all?
> 
> The answer is easy: the opCall for a reference of its own class 
> should be disallowed.

And thereby lose the ability to use it for lambda-calculus/combinator stuff?

> By the way: the ._= seems to be a useful shorthand for overloading an 
> assignment :-)

Use it if you like.  But the basic question is: Why do you want to 
overload the assignment operator?

http://www.digitalmars.com/d/faq.html#assignmentoverloading

>> Similarly,
>>
>>      void function(int) qwert;
>>      ...
>>      qwert(yuiop);   // calling the pointed-to function
>>      qwert = asfdg;  // changing which function is pointed to
> 
> That is also easy: no qwert can have its own type as a single 
> parameter. Otherwise show me an example.
> 
> Therefore its distinguishable whether a "=" is a call or an 
> assignment.

It's distinguishable at the moment by whether the lvalue is a variable 
or a function.

Trying to add a further dependence on the type of the rvalue would make 
the language more complicated and possibly harder to understand.

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