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

> Ada is pretty much still the only language that has this.

Common Lisp does too:

    (deftype quantity () '(integer 0 240))
    (defun foo (x)
      (declare (type quantity x))
      (1+ x))
    (foo 1) → 2
    (foo -1) → ERROR
    (defun valid-username-p (string)
      (and (< 8 (length string) 24)
           (every (lambda (char)
      (find char "abcdefghijklmnopqrstuvwxyz0123456789-_=./" :test #'char=))
    string)))
    (typep "foo" 'username) → NIL
    (typep "foobarbaz" 'username) → T
    (typep "foobar-baz" 'username) → T
    (typep "foobar-baz " 'username) → NIL
Common Lisp is pretty awesome.


Well, except for the fact that it's Common Lisp. ;)




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

Search: