{define-proc {foo}:String
{error "not implemented yet"}
}
The compiler knows that the 'error' function will always throw an exception and will therefore not complain that the function lacks a return statement. To create your own function like 'error', you only need to make a procedure that always throws an exception and that has a declared return type of 'never-returns':
{define-proc {unimplemented}:never-returns
{error "not implemented yet"}
}
I have done one better than this by creating an 'unimplemented' syntax in the ZUZU.LIB.SYNTAX package that uses Curl's 'this-function' syntax to add the name of the unimplemented function to the error message. For example:
You can find the source of this macro here.
The ability to extend the syntax like this makes Curl a much more expressive language than most widely used languages today.
No comments:
Post a Comment