From:

Date:

March 7, 2001 14:18Subject:

Re: [ID 20010305.005] "use integer" doesn't make rand() return integersMessage ID:

20010307221533.20193.qmail@foad.orgOn Wed, Mar 07, 2001 at 04:35:43PM -0500, John Peacock wrote: > abigail@foad.org wrote: > > > > > > If there was no point, why was it requested? "No point" is merely > > your opinion, nothing more or less. > > Just because a single user expected 'use integer' to overload rand is > no reason to add it Perl. Next a user will wonder why sin or tan don't > return only integers when 'use integer' is in place. And soon, some > other user will wonder why all function calls (including user defined) > are not cast to integers when 'use integer' is in effect. Well, it would make sense, wouldn't it? After all, does it make any sense that '* 1' isn't an identity operation? I find: 1 * sin (1) != sin (1) to be utterly unintuitive. Now, I don't really care in this case because trig functions aren't particular useful when doing integer arithmetic. > > I find rand() returning integers nothing stranger than 3.7 + 1.6 > > equalling 4. > > rand() returns a floating point number from 0 to < 1. There is but > a single integer in that range. It would be faster to code 'sub {0}' > and leave it at that. Blech. Sure, if you have the characters 'r', 'a', 'n', 'd', '(', ')' in your code, yeah. I'm talking about the function rand() in general (as opposed to rand, the coin). Which takes an optional parameter. > > Why would you *want* rand() to return non-integers if you are doing integer > > arithmetic anyway? > > My point exactly! There is a conceptual failure here, not a limitation > of Perl. If a user wishes to have a random integer between 0 and 9 > inclusive, the simple line of code: > > int( rand(10) ); > > is sufficient. There is no reason to change the meaning of 'use > integer' > to suit one person's DWIM. If a person wants to do integer addition, a simple: int ($a) + int ($b) is sufficient. By the same argument, adding the square root of 2 to the square root of 3 is a conceptual failure if you have declared to do integer arithmetic. Heh, I can live with rand() not returning integers, but I can live with + not returning integers in the same way. But I won't accept the argument that rand() returning integers with 'use integer' is in scope is illogical. AbigailThread Previous | Thread Next

- [ID 20010305.005] "use integer" doesn't make rand() return integers by fanf
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by rspier
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John L. Allen
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by rspier
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by rspier
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Walt Mankowski
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by abigail
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John L. Allen
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Philip Newton
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Tony Finch
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Philip Newton
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by rspier
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Philip Newton
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by abigail
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by abigail
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock
**Re: [ID 20010305.005] "use integer" doesn't make rand() return integers**by abigail- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Ronald J Kimball
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Bryan C . Warnock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by abigail
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Bryan C . Warnock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Nicholas Clark
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Bryan C . Warnock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by abigail
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by Bryan C . Warnock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock
- Re: [ID 20010305.005] "use integer" doesn't make rand() return integers by John Peacock

nntp.perl.org: Perl Programming lists via nntp and http.

Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About