On 12 Oct 2008, at 9:28 pm, Henning Thielemann wrote:


On Thu, 9 Oct 2008, Iain Barnett wrote:

If I were to create an object in C#, for instance, I could add code to the constructor that might limit the type further e.g.


public class Car
{
        string model;
        int wheels;

        public Car ( string model, int no_of_wheels )
        {
                if (  no_of_wheels <= 2 ) {
                        throw new Exception( "a car must have at least 3 
wheels");
                }
                                this.model = model;
                this.no_of_wheels = no_of_wheels;
        }
}

I think it is not the right way to handle the number of wheels with an exception. This should be considered an error.
   http://www.haskell.org/haskellwiki/Error

Only if you think through the code you're writing - i.e. non idiomatic C# ;)

Iain



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to