(Cross posted from the Zuzu Curl blog.)
Frequently I find that I want to quickly sketch out the interface of a function or class method and compile it without actually implementing its body. If the function does not return any arguments, I can simply leave the body empty, but if it does return something, I might need to write a fake return statement to make the compiler happy. In either case, I usually want to leave myself a reminder that the code still needs to be implemented. In Curl, this can easily be done using an exception:
{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.
