-> and :: operators

Ola Fosheim Grøstad via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 11 08:32:42 PDT 2015


On Sunday, 11 October 2015 at 09:43:04 UTC, Idan Arye wrote:
> This is the innovation in D(regarding this issue) - that on 
> struct types, the same operator is used for BOTH the value type 
> and the pointer to it.

BETA is the successor to Simula and it does not distinguish 
between value or reference and only use dot reference. What they 
do instead of having a dereference operator is to have a 
"reference operator" and also a "pattern operator" for type 
variables. So it works something like this:

Call a and send the output as the input to b and then store the 
result:

     (1,(2,3)) -> a -> b -> (c,(d,e))

Assign reference a to b (instanced class/function)

     a[] -> b[]

Replace class-type variable a with class-type b (not instanced, 
which is equivalent to a class-type/function pointer)

      a## -> b##

It makes a lot of sense for an OO language since we usually use 
the referenced content more often than we want to change the 
pointer.



More information about the Digitalmars-d mailing list