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

RE: cheerful static typing (was: Any and Every... (was: Eval))




> Please show me for a small essential core model of Curl
> what typing means. The more I see about Curl's type system
> the more I am confused. Let me point to two examples
> that most people on the list should know and understand.

Curl's type system is "safe", like Java's, i.e. you cannot do reinterpret
type casts.  In fact, the type system is similar to Java's in many respects.
The main differences are:

 - Curl supports multiple inheritance
   (and thus has no need for interfaces)
 - it supports parameterized class types
 - it has quantity types: numeric types with
   dimensioned units (e.g., distance, time, mass).
 - it has different static type annotations for expressions
   that are allowed to have a null value (e.g. you can assign
   a null to a #String variable, but not a String)
 - it has procedure types
 - it has implicit constructors/factories that allow
   you to define implicit conversions to user defined
   classes
 - it has a static type 'any', which may hold any value
   and for which static type checks are suppressed subject
   to modification by compiler directives
 - type annotations are optional, and if omitted default to
   'any', but a compiler directive can make this illegal.

"Compiler directives" in Curl are always specifed in the source code, not
the development environment, and may enable errors for constructs that could
produce runtime type errors or generate slow code because of lack of static
type information.

One gotcha is that since Curl compiles lazily whenever it can, many
compilation errors can be deferred until "runtime".  So it is possible to
miss compilation errors during development unless you have a good test suite
or have disabled lazy compilation during testing.

Hope that helps clear up the confusion.

- Christopher