From: Bob Alexander Date: 2002-03-13T01:26:44+09:00 Subject: Some potential RCRs This is a multi-part message in MIME format. ------=_NextPart_000_0067_01C1C99F.EDC2BC70 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Here are a few thing I am considering submitting as RCRs. I'm looking = for comments to help decide whether to make them official, so please let = know what you think is good and bad about these... ------------------ "p" method should return its last argument, unconverted. (It currently returns nil.) This would allow it to be more conveniently = inserted into expressions during debugging: E.g. in a =3D d + b / c To quickly see what the subexpression (b / c) is producing a =3D a + p(b / c) or a =3D d + p("***** b / c:", b / c) ------------------ A format specification in "printf"-type formats that inserts the result = of applying "inspect" to the argument. E.g. "Value of x: %r\n" % x. This is more convenient than typing ".inspect". There are some other = reasons why it is better to specify inspectness in the format rather = than pre-evaluating inspectness in the argument. One is for specifying = logging messages: the inspect string need not be computed if the logging = message is suppressed. I used %r in my example only because it is used = in Python for the same functionality, which I find useful. Python uses = %r because their equivalent of "inspect" is "repr" -- for Ruby a = different letter might be better. Too bad %i is already overloaded for = integers! ------------------ A "println" method. Would work just like "print" but would tack on a newline. Yeah, I know = it doesn't seem much different than just coding "\n" as a final = parameter, but I find "println" more pleasing and more self-describing ------------------ String#count should also accept Regexp as argument. Would extend the power of this method. ------------------ Dir methods that produce directory entries should never produce "." and = "..". I see no use in producing "." and "..", and it is a nuisance having to = explicitly filter them out (usually after forgetting to do it and = getting a program error!) Also, seems a tad non-portable. ------------------ The built-in Mutex object should be nestable. Acquiring a mutex in nested contexts in the same thread should not cause = deadlock. It doesn't seem appropriate for a language at Ruby's level to = have a non-nestable Mutex, and it is a pothole for program errors. ------------------ A "message" parameter for "abort". Coding abort("the program did something bad") would print the message before terminating. Note: Python does something kind of nifty in this area which I like: exit() exits with code=3D0 exit(22) exits with code=3D22 exit("bad bad") prints "bad bad" and exits with code=3D1 I think this would be a good thing in Ruby too (hey, the Python camp = seems to be very busy lately copying Ruby's good ideas!) ------------------ Enhanced ObjectSpace finalizer operations I started a separate thread on this: "Thoughts on WeakRefs and = ObjectSpace". Bob ------=_NextPart_000_0067_01C1C99F.EDC2BC70 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Here are a few thing I am considering = submitting as=20 RCRs. I'm looking for comments to help decide whether to make them = official, so=20 please let know what you think is good and bad about = these...
 
 
------------------
"p" method should return its last = argument,=20 unconverted.
 
(It currently returns nil.) This would = allow it to=20 be more conveniently inserted into expressions during = debugging:
E.g. in
   a =3D d + b / = c
To quickly see what the subexpression = (b / c) is=20 producing
   a =3D a + p(b / = c)
or
   a =3D d + = p("***** b / c:", b=20 / c)
 
 
------------------
A format specification in "printf"-type formats that inserts the = result of=20 applying "inspect" to the argument.
 
E.g. "Value of x: %r\n" % x.
 
This is more convenient than typing ".inspect". There are some = other=20 reasons why it is better to specify inspectness in the format rather = than=20 pre-evaluating inspectness in the argument. One is = for specifying=20 logging messages: the inspect string need not be computed if the = logging=20 message is suppressed. I used %r in my example only because it is used = in Python=20 for the same functionality, which I find useful. Python uses %r because = their=20 equivalent of "inspect" is "repr" -- for Ruby a different letter might = be=20 better. Too bad %i is already overloaded for integers!
 
 
------------------
A "println" method.
 
Would work just like "print" but would tack on a newline. Yeah, I = know it=20 doesn't seem much different than just coding "\n" as a final = parameter, but=20 I find "println" more pleasing and more self-describing
 
 
------------------
String#count should also accept Regexp as argument.
 
Would extend the power of this method.
 
 
------------------
Dir methods that produce directory entries should never produce "." = and=20 "..".
I see no use in producing "." and "..", and it is a nuisance having = to=20 explicitly filter them out (usually after forgetting to do it and = getting a=20 program error!) Also, seems a tad non-portable.
 
 
------------------
The built-in Mutex object should be nestable.
 
Acquiring a mutex in nested contexts in the same thread should not = cause=20 deadlock. It doesn't seem appropriate for a language at Ruby's level to = have a=20 non-nestable Mutex, and it is a pothole for program errors.
 
 
------------------
A "message" parameter for "abort".
 
Coding
 
    abort("the program did something bad")
 
would print the message before terminating.
 
Note:
Python does something kind of nifty in this area which I = like:
   exit()  exits with code=3D0
   exit(22) exits with code=3D22
   exit("bad bad") prints "bad bad" and exits with = code=3D1
I think this would be a good thing in Ruby too (hey, the Python = camp seems=20 to be very busy lately copying Ruby's good ideas!)
 
 
------------------
Enhanced ObjectSpace finalizer operations
 
I started a separate thread on this: "Thoughts on WeakRefs and=20 ObjectSpace".
 
 
Bob
------=_NextPart_000_0067_01C1C99F.EDC2BC70--