[eeps] comments on eep8

David Hopwood david.hopwood@REDACTED
Wed Jan 9 18:40:39 CET 2008


Joe Armstrong wrote:
> 10) In the spirit of 9) I'd like to have user defined type checking
> 
>     @spec xxx(foo:bar) -> baz:oop
> 
>     This means that the arg 1 of xxx is of type X if foo:bar(X)
> evaluates to true.
> 
>     The point of this is to move towards describing the properties of a system
> which can only be checked at run-time and not compile time.
> 
>     Then we could have types like fileMustExist() meaning the file
> must exist at run time.
> 
>     Today a file is just a string (type wise) but we might like to document
>   the fact that this string represents a file that *must* exist.

That isn't a good example, because whether or not the file exists is not
a property of the string. A file with a given path relative to a given
filesystem root may exist one second and not exist the next, so the use
of predicate types to assert its existance would be inherently prone to
race conditions.

But I agree that predicate types can be useful, when they specify pure
boolean functions of immutable values.

-- 
David Hopwood



More information about the eeps mailing list