J
Just Another Victim of the Ambient Morality
So, I had a conversation with a colleague of mine and he brought up a
feature request for another language that is a lot like Ruby but is not
Ruby. It was an interesting request and, after I had thought about it a
bit, I discovered that I would like this feature, too!
The two most popular sources of bugs for me when programming in Ruby
are:
1) Passing the wrong object as a parameter to a method.
2) Accidentally creating a new variable.
Unfortunately for me, very little can be done about my first point. I
understand and enjoy the power of duck-typing, which specifically allows me
to exercise this bug.
However, something can be done about the second point. Let me exemplify
the problem:
list = create_useful_list
if should_modify_list(list)
# I meant to modify the variable "list" here...
liist = modify_list(list)
end
use_list(list)
...obviously, this is a seriously contrived example but it should
clarify my point. I so amazingly meant to assign to the pre-existing
variable "list" but I accidentally created a new variable. It's not even
typos with me. I often thought I named a variable something descriptive
when I actually named it something else equally descriptive. This can be a
surprisingly annoying bug to track...
A solution to my problem would be to require variable declarations.
Something like the "my" keyword of a strict PERL script. Ruby would
probably not use "my," despite its PERL roots. Maybe "var?"
var list = create_useful_list
if should_modify_list(list)
# A compile time error will occur here...
# ...after 1.9 is released...
liist = modify_list(list)
end
use_list(list)
What do you all think?
Thank you...
feature request for another language that is a lot like Ruby but is not
Ruby. It was an interesting request and, after I had thought about it a
bit, I discovered that I would like this feature, too!
The two most popular sources of bugs for me when programming in Ruby
are:
1) Passing the wrong object as a parameter to a method.
2) Accidentally creating a new variable.
Unfortunately for me, very little can be done about my first point. I
understand and enjoy the power of duck-typing, which specifically allows me
to exercise this bug.
However, something can be done about the second point. Let me exemplify
the problem:
list = create_useful_list
if should_modify_list(list)
# I meant to modify the variable "list" here...
liist = modify_list(list)
end
use_list(list)
...obviously, this is a seriously contrived example but it should
clarify my point. I so amazingly meant to assign to the pre-existing
variable "list" but I accidentally created a new variable. It's not even
typos with me. I often thought I named a variable something descriptive
when I actually named it something else equally descriptive. This can be a
surprisingly annoying bug to track...
A solution to my problem would be to require variable declarations.
Something like the "my" keyword of a strict PERL script. Ruby would
probably not use "my," despite its PERL roots. Maybe "var?"
var list = create_useful_list
if should_modify_list(list)
# A compile time error will occur here...
# ...after 1.9 is released...
liist = modify_list(list)
end
use_list(list)
What do you all think?
Thank you...