[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rather, DSSLs increase modularity, productivity



> Incidentally, I don't understand your point about ML: it doesn't have
> a cast operator, so it seems like it's vacuously the case that it can
> never fail a cast.

I don't know if this is what he had in mind, but a failed pattern
match is similar to a failed cast.  In OCaml, consider something
like:

type foo = A | B

let f A = true

Here you can evaluate (f B) and it will pass the type checker (with
a warning) but raise an exception at runtime.  If we say that the
approximate equivalent in Java is:

class foo {}
class A extends foo {}
class B extends foo {}
class f {
  public bool f(foo x) {
    A a = (A) x;
    return true;
  }
}

then ML's failed pattern match error looks a lot like a casting
error.

- Russ