Andre Pang wrote:
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
Time is set to HOUR, and so the interpreter (compiler) will increment by
hours.
If Time is set to MINUTE, the interpreter will increment by minutes.
and so forth.
Today is set to DAY, and so the interpreter will increment by days.
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.
RRFN - Make it RUN; Make it RIGHT; Make it FAST; Make it NICE is a
long way of saying test your codes.
TDD is Test Driven Development.
(And RRFN and TDD is yet another example of why I _very_ rarely use
abbreviations when I'm coding.)
O Plameras
_______________________________________________
coders mailing list
[email protected]
http://lists.slug.org.au/listinfo/coders