Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In pascal, you could have user-typed primitives, with conversion code for cast. For example, you could have celcius and fahrenheit float types. If you used a celcius when fahrenheit was wanted, the conversion code would automatically be called.

I saw an article years ago (by Joel?) about applying this mechanism to html-encoding: so if you used an unescaped type where an escaped type was required, it was automatically converted. This provided security against injection attacks.

Similarly, you can have validated and unvalidated types. If your libraries/frameworks already used these, there's almost no work left for you to do.

Of course, java doesn't have user-typed primitives, nor type-conversion code. In XSD datatypes you can specify a string type in terms of a regular expression http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: