Simple question: Should I be bothered by...



  • @RaspenJho said:

    That makes sense... I would however expect that a horse class that implements a "Kill" method would end up with a dead horse.

    Horse.Kill().Flog();



  • @Ragnax said:

    @TheCPUWizard said:
    If the "FuctionGetInts()" all of a sudden was reworked to return doubles (a WTF given the name, but that is irrelevant) then you would get a compiler error (which is good).

    Not in C# 4.0. With the added support for covariance on the IEnumerable<T> interface, it is perfectly valid to cast an instance implementing IList<double> to IEnumerable<int>.

    Nope covariance only works with the object hierarchy, not with "convertible" types.



  • XIU, you are 100% correct, and I should have pointed that out in my previous response (which dealt with the usage of "in" and "out" keywords to control covariance/contravariance).

    Since numeric types are not implemented as a hierarchy (for good reason!) a converter would be needed. This *can* be made nearly transparent, but must be explicitly implemented (as some "number crunching" libraries do.



  • @b-redeker said:

    @RaspenJho said:

    That makes sense... I would however expect that a horse class that implements a "Kill" method would end up with a dead horse.

    Horse.Kill().Flog();

    Literal LOL.


  • @RaspenJho said:

    @b-redeker said:

    @RaspenJho said:

    That makes sense... I would however expect that a horse class that implements a "Kill" method would end up with a dead horse.

    Horse.Kill().Flog();

    Literal LOL.

     Just remember with the use of Lambdas and/or Proxy classes, nested calls like this may not actually occur in the "visible" order. This is one of the reasons the Demeter project disallowed them. It is quite possible (any useful - although cruel) that this could result in the horse being flogged and then killed.



  • @TheCPUWizard said:

    @RaspenJho said:

    @b-redeker said:

    Horse.Kill().Flog();

    Literal LOL.

     Just remember with the use of Lambdas and/or Proxy classes, nested calls like this may not actually occur in the "visible" order. This is one of the reasons the Demeter project disallowed them. It is quite possible (any useful - although cruel) that this could result in the horse being flogged and then killed.

    Joy.Kill(); // :(



  • CPUWizard, you promised me other good book names!


Log in to reply