[#1026] Is this a bug? — Dave Thomas <Dave@...>
18 messages
2000/01/03
[#1053] rand() / drand48() — ts <decoux@...>
11 messages
2000/01/05
[#1055] Re: rand() / drand48()
— matz@... (Yukihiro Matsumoto)
2000/01/05
[#1061] Re: rand() / drand48()
— gotoken@... (GOTO Kentaro)
2000/01/07
Hi,
[#1067] Here docs not skipping leading spaces — Dave Thomas <Dave@...>
5 messages
2000/01/08
[#1083] YADQ (Yet Another Dumb Question) — Dave Thomas <Dave@...>
12 messages
2000/01/10
[#1084] Infinite loop — Dave Thomas <Dave@...>
17 messages
2000/01/11
[#1104] The value of while... — Dave Thomas <Dave@...>
24 messages
2000/01/11
[#1114] Re: The value of while...
— Dave Thomas <Dave@...>
2000/01/12
matz@netlab.co.jp (Yukihiro Matsumoto) writes:
[#1128] Re: The value of while... — David Suarez de Lis <excalibor@...>
Hi all,
1 message
2000/01/12
[#1133] Re: Class variables... — David Suarez de Lis <excalibor@...>
Hi there,
2 messages
2000/01/12
[#1158] Is this expected behavior? — Dave Thomas <Dave@...>
6 messages
2000/01/21
[#1172] Re: Possible bug in ruby-man-1.4 — Huayin Wang <wang@...>
> |Well, I guess it comes down to what you mean by an integer
10 messages
2000/01/24
[#1177] Re: Possible bug in ruby-man-1.4
— Dave Thomas <Dave@...>
2000/01/25
matz@netlab.co.jp (Yukihiro Matsumoto) writes:
[#1188] Enumerable and index — Dave Thomas <Dave@...>
5 messages
2000/01/27
[#1193] Semantics of chomp/chop — Dave Thomas <Dave@...>
7 messages
2000/01/28
[#1197] Question about 'open' — Dave Thomas <Dave@...>
8 messages
2000/01/30
[ruby-talk:01168] Re: Possible bug in ruby-man-1.4
From:
Dave Thomas <Dave@...>
Date:
2000-01-24 03:29:49 UTC
List:
ruby-talk #1168
matz@netlab.co.jp (Yukihiro Matsumoto) writes: > You are right. I'd like to hear your opinion about this. > > -13.remainder(4) => (-13).remainder(4) or -(13.remainder(4)) > -foo.remainder(4) => (-foo).remainder(4) or -(foo.remainder(4)) Well, I guess it comes down to what you mean by an integer literal. Right now, we have a somewhat confusing situation: a = -2 assigns '-2' directly to a a = -2.+(3) generates 5:Fixnum, then applies -@, resulting in -5. I think that breaks most people's expectations. When they see -99, they think of the number '-99', not 99 negated. When they see -2.abs, I think they'd expect to see 2, not -2. So, I'd personally feel that it's more natural to do a lookahead on MINUS for a digit, and if found, generate the negative number directly. That way -2.+(3) would parse as (-2).+(3). When it comes to -a.abs(), I think the argument is subtly different. I suspect most people would look at that in any programming language and stop to think about precedence. They might bracket it to be safe. I don't think they have too many ingrained expectations, the way we have with negative numbers. So, I could argue -a.abs() either way, and leave it up to the language designer to tell me the precedence rules. I think the goal is to have a language with the fewest number of surprises--one that doesn't have built-in "gotchas". -2.abs is a surprise to most people. Regards Dave -- Thomas Consulting. Innovative and successful developments with Unix, Java, C, and C++. Now in bookstores: The Pragmatic Programmer. www.pragmaticprogrammer.com/ppbook/