Hi,

> What kinds of type errors do you typically run into? Procedure calls
> on non-procedures? Trying to access record indexes that don't exist?
> Float/int confusion? I'm interested in implementing a static type
> checker for Oz, and I'm trying to gather data as to what kind of
> type-checking to focus on.
>

the problem is that quite a lot of data is stored in cells or object
attributes. This makes the contents anonymous, so extra effort is needed
when you want to check the usage of this data during compilation. I use
something like this:

meth do_something
  [EMAIL PROTECTED]
in
  {Ensure Square}=SquareO
  if SquareO==null then skip else
    {SquareO paint}
  end
end

which, in the check-build phase, gets translated by my preprocessor to

meth do_something
  [EMAIL PROTECTED]
in
  {New Square noop}=SquareO
  if SquareO==null then skip else
    {SquareO paint}
  end
end

which enables the compiler to check that "paint" is a valid method in
class Square, and in the production build the code is

meth do_something
  [EMAIL PROTECTED]
in
  if SquareO==null then skip else
    {SquareO paint}
  end
end

(i.e. the check is removed). Simple 'sed' preprocessing. :-) I think
similar approach could be used for int/float checking. I also use this
to check data structure (record) access, by defining 'empty' global
record instances, like

CheckStruct_myStruct=myStruct(feature1:_ feature2:_)

and doing

proc {SomeProc Arg}
 CheckStruct_myStruct=Arg
 {Browse Arg.feature1}
end

This checks that feature1 is valid for the 'myStruct' record.

Another problem is that accessing features of an object via
self.feature_name or attributes via @attribute_name does not allow for
static access (like with static method calls) - I understand that this
is by design - so it is never checked that the class actually contains
the feature/attribute in question. But this is not so big problem in
most cases since this is a matter of a single class implementation, so
it is not so hard to maintain consistence within the class. Cross-class
references can be, with some effort, solved with the preprocessor.

If someone has another/better ideas, please share them!

Hope this helps,
Filip


_________________________________________________________________________________
mozart-hackers mailing list [email protected] http://www.mozart-oz.org/mailman/listinfo/mozart-hackers

Reply via email to