Short overview on D

anonymous via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 3 04:46:48 PDT 2014


On Sunday, 3 August 2014 at 10:57:26 UTC, Bayan Rafeh wrote:
> -- Functions --
>
>>> Ref implies the type is a reference type
[...]
>> `ref` doesn't "imply" a reference, it "declares" or "states" or
>> something.
> I'm basing this on the wiki: http://dlang.org/function.html
> "ref	parameter is passed by reference"
>
> If that is not the case, in practical terms what does that mean 
> exactly?

I'm just picking on the word "implies". Making the parameter be
passed by reference is `ref`'s sole purpose. When you say that
`ref` implies pass by reference, I'd expect it to mainly do
something else, which it doesn't. I'm not a native English
speaker, though, so I may be completely off here.

>> -- Operator Overloading --
>>
>> The wording suggests that the list of operators is supposed to 
>> be
>> exhaustive. It's not.
>>
> I intended it to be comprehensive(with regard to types at 
> least). What am I missing regarding the different types of 
> operators besides the opAssigns?

There's logical operators (&& ||), bitwise operators (& | ^ <<
etc), ~ for array concatenation, and others. These all fall under
opBinary, but calling them mathematical would be misleading (at
least to me).

`c ? t : f` is the "ternary operator". It can't be overloaded,
though.

You can overload `cast` (opCast) and `foreach` (range primitives
or opApply). I'm not sure if they're proper operators.

There's probably more.

>> -- Templates --
>>
>>> Templates are D's response to Java generics and C++ templates.
>>
>> At least put C++ first if you have to include Java ;)
>>
> Riots would ensue. To put it lightly we're not fans of C++. 
> Well we're not exactly fans of Java either :p

The point is, D's templates are related more closely to C++'s
template than to Java's generics.


More information about the Digitalmars-d mailing list