On 13/09/2006, at 4:35 PM, O Plameras wrote:

Andre Pang wrote:

  "foo" + 5

What about,

today + 1  =  14 Sept 2006 if today is 13 Sept 2006
or
time +1 = 5pm if time is 4pm

Your example demonstrates two problems. First, "foo"+5 may be valid in a statically typed language that permits automatic type conversions to be done (such as C++), although you'd need a definition for the type conversion to take place. So this doesn't really have anything to do with dynamic typing.

Second, what's time+1? Let's assume that automatic type conversion here is what you want. time+1 could now mean:

 * Add one hour to the time
 * Add one minute to the time
 * Add one second to the time
 * Add one microsecond to the time

Take your pick. I'd rather wrap the '1' value in some sort of function call or object constructor that (1) turns the '1' into some sort of Time type, and (2) clearly indicates that the '1' means 1 second/1 hour/etc.

There is always RRFN or TDD, anyway.

What's RRFN and TDD? If TDD means test-driven development, that's no substitute for a type system, and vice versa.

(And RRFN and TDD is yet another example of why I _very_ rarely use abbreviations when I'm coding.)


--
% Andre Pang : trust.in.love.to.save  <http://www.algorithm.com.au/>



_______________________________________________
coders mailing list
coders@slug.org.au
http://lists.slug.org.au/listinfo/coders

Reply via email to