From: John Meacham <john@foo.net>
Subject: language suggestion
Newsgroups: comp.lang.sather
Date: Wed, 16 Jun 1999 07:10:56 -0700
sorry if this has already been discussed or even implemented...
how about an expression that would generate a COMPILE time error if the
expression is ever code generated in a program. my reasoning is this...
often one will do something like this
(to use a canonical example.)
class ORD is
is_leq(o:$ORD):BOOL is
raise "<= is not implemented in this incomplete class";
end;
is_geq(o:$ORD):BOOL is
return (o <= self);
end;
...
then to be used as
class NUM is
include ORD
is_leq->;
is_leq(...):BOOL is ... end;
...
end;
now the problem is that if we forget to overide is_leq, it is not caught
by the compiler... we get it only at run time and then only if that
routine is attempted.... this style of coding seems to be prevalant. now
if we were to do
class ORD is
is_leq(o:$ORD):BOOL is
comperror "ORD::is_leq must be overriden.";
end;
end;
class NUM is
include ORD;
...
end;
then if we try to compile the code we get a nice error pointing at where
the offending include. This would also seem to take care of the need of
partial classes and (maybe? maybe not?) is possibly more elegant in the
context of sathers clear distinction between include/inheritence
semantics....
<<snip>>
-----------------------------------------------------------------------
From: Erik Schnetter <schnette@tat.physik.uni-tuebingen.de>
Subject: Re: language suggestion
Newsgroups: comp.lang.sather
Date: 16 Jun 1999 15:14:20 GMT
<<snip>>
Ah! What a wonderful idea. But it is already there. It is called
"partial classes" and "stub"s. You'd write
partial class ORD is
stub is_leq(o:$ORD):BOOL;
is_geq(o:$ORD):BOOL is
return (o <= self);
end;
...
-erik
|