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

Re: Rather, DSSLs increase modularity, productivity

Shriram Krishnamurthi wrote:

> So suppose I have (in pseudocode):
>f() =
>  let x : ref int = box 3
>  in
>    g(x) ;
>    (unbox x) + 5
>g(y) =
>  set-box y = true
>Then what does the Curl "type system" do?
>Please don't tell me about your compiler.  Just tell me what your type
>system does.  (And please square it with your comments that the
>implementation will "check types" and "generate better code".)
In this case, since y has no declared type it, its static type would be 
'any' so the type mismatch would not be noticed until runtime.  Curl 
does not do any type inferencing (except in a few special cases) so the 
compiler will not recognize this error at compile time.

Note that Curl's 'any' type is not merely the universal supertype.  It 
also has different behavior from other static type constraints.  When a 
variable has the 'any' static type, then no compile-time checks will be 
performed for method dispatches through the variable.  For variables 
with any other static type,  method invocations must conform to the 
static type.  For example:

     {define-class A}
     {define-class B {inherits A} {method {b}}}
      let x:A = {B}
      let y = x
      {y.b} || ok
      {x.b} || error, no member 'b' defined in 'A'

Curl's type system is probably not all that interesting from a 
theoretical standpoint but it does allow the programmer to choose 
between dynamic and static programming styles as they see fit.

- Christopher