xxxInPlace or xxxCopy?

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Jan 20 12:21:22 PST 2011


On 1/20/11, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> On Thursday 20 January 2011 03:51:48 Trass3r wrote:
>> If such an annotation was introduced, it should be the other way around.
>> But imo discarding a return value should always result in a warning,
>> the function returns something for a reason.
>
> Actually, there are plenty of cases where you throw away the return value.

Yeah. There are functions that can return a value that also have
side-effects. An example might be a class method that modifies it's
private fields and might return the number of fields that were
affected. While you might not need the return value in most cases, you
do want the side-effects to happen. That's why forcing an error on
functions that return values which aren't used would not be a good
idea, and where the annotation idea comes from.


More information about the Digitalmars-d mailing list