archives

Interesting old gem: Prop does pattern matching in C++

I wonder why I haven't heard more about Prop.

It lets you do ML-style pattern matching in C++. Perhaps a nifty way to sneak in a little functional programming at work.

(noob question) method parameters in co-and-contravariance issue

Is co- and contravariance a concept related to inheritance or can it apply to normal method parameters ?
See definition at c2.com.

e.g. In java

    class Food{}
    class Grass extends Food {}
    class Antelope extends Food {}
    public class Main2
    {
        public static void main(String[] args) {
            Main2.eat( new Food() );
            Main2.eat( new Grass() );
            Main2.swallow( new Food() ); // compile-time error
            Main2.swallow( new Grass() );
        }
        public static void eat( Food f ) {}
        public static void swallow( Grass f ) {}
    }


So I get a compile-time error because the method parameters to swallow is covariant i.e. it only accepts Grass and its subtypes.

Am I correct in my reasoning ? Thanks

Correct mathematical symbol to represent "subtype"

If this question doesn't make sense, it's probably because I might be confused with the term subtype.

What is the correct mathematical symbol for subtype ?
if B is a subtype of A, which do I write:

  1. B ≤ A
  2. B <: A

Thanks.

Arc is released

Make of it what you will, but Arc is now officially released.

This part of Graham's announcement is a gem:

I worry about releasing it, because I don't want there to be forces pushing the language to stop changing. Once you release something and people start to build stuff on top of it, you start to feel you shouldn't change things. So we're giving notice in advance that we're going to keep acting as if we were the only users. We'll change stuff without thinking about what it might break, and we won't even keep track of the changes.

I realize that sounds harsh, but there's a lot at stake. I went to a talk last summer by Guido van Rossum about Python, and he seemed to have spent most of the preceding year switching from one representation of characters to another. I never want to blow a year dealing with characters. Why did Guido have to? Because he had to think about compatibility. But though it seems benevolent to worry about breaking existing code, ultimately there's a cost: it means you spend a year dealing with character sets instead of making the language more powerful.

This sure made me smile...