Long Live Static Typing!

  • user warning: Table 'nolan.comments' doesn't exist query: SELECT COUNT(*) FROM comments WHERE nid = 212 AND status = 0 in /home/sneakin/web/nolan.eakins.net/includes/database.mysql.inc on line 120.
  • user warning: Table 'nolan.comments' doesn't exist query: SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread, c.status FROM comments c INNER JOIN users u ON c.uid = u.uid WHERE c.nid = 212 AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread, c.status ORDER BY c.thread DESC LIMIT 0, 50 in /home/sneakin/web/nolan.eakins.net/includes/database.mysql.inc on line 120.

I just read an article that mentioned dynamic and statically typed languages, and I also just looked up Ruby's yield statement. One of the examples on the page I found was this:

class SongList
  def [](key)
    if key.kind_of?(Integer)
      @songs[key]
    else
      # ...
    end
  end
end

The problem I have is with the if key.kind_of?(Integer). I've been toying with Lisp some, and it reintroduces static typing (think C/C++ function/method arguments). So the above could be simplified a lot, especially if a method needed to be specialized for a ton of types. This could be done by specifying an argument's type. The following would work perfect, and could allow some optimizations to be made too:

class SongList
  def [](Integer key)
    @songs[key]
  end

  def [](key)
    # ...
  end
end

Ad's by Google