Re: Thoughts and proposals about types and classes

Jack Jansen (Jack.Jansen@cwi.nl)
Mon, 13 Sep 1993 11:51:08 +0200

The point of my original example was indeed that the allowed()
expression was *not* evaluated, so that possible side-effects are no
problem. Otherwise the try/except construct woudl be good enough
(except for the fact that it doesn't really lead to well-structured
code in all cases).

There's a serious flaw in the whole idea, though, that was pointed out
by Dik Winter: the semantics are unclear. If I say "allowed(x+1)" it
is clear enough (even though there are implementation difficulties, as
Tim pointed out): check wether x has an add method that supports
integer arguments. If I say "allowed(foo())" ditto, I think: check that
foo is a function. If I say "allowed(foo()+1)" it becomes undecidable
without calling foo, since foo might return a different type depending
on the phase of the moon.

Even a restriction that you may use only one operator within the
allowed() expression is not good enough: you really want to be able to
say "allowed(len(x))", but here we're already testing two things:
besides testing wether x has a length (which is probably what we want
to test) we also test that len is a function. Moreover, we actually
use the semantics of len for the test we are really interested in, and
I can't see an easy way of doing that without executing len.

Oh well, another interesting idea down the drain,

--
Jack Jansen        | If I can't dance I don't want to be part of
Jack.Jansen@cwi.nl | your revolution             -- Emma Goldman
uunet!cwi.nl!jack    G=Jack;S=Jansen;O=cwi;PRMD=surf;ADMD=400net;C=nl