Another typedef usage example

Shin Fujishiro rsinfu at
Sat May 8 12:28:08 PDT 2010

Yet another example:
typedef string URIEscapedString;
URIEscapedString escapeURI(string s);
void[] requestWebResource(URIEscapedString safeuri);

void main() {
        // Error: cannot implicitly convert ...
In this code, you cannot pass a "raw string" to requestWebResource().
Any raw string must be URI-escaped with escapeURI() before used as a
valid URI, or it won't compile.

This would be applicable to SQL sanitization, input validation, etc.

I read it somewhere that some programmers use Hungarian notation to do
the same thing.  But Hungarian prefixes are not checked by compier.

More information about the Digitalmars-d mailing list