Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: 2 + 2 = 5

Reply
Thread Tools

Re: 2 + 2 = 5

 
 
Cameron Simpson
Guest
Posts: n/a
 
      07-05-2012
On 04Jul2012 19:39, Evan Driscoll <(E-Mail Removed)> wrote:
| On 7/4/2012 14:37, Paul Rubin wrote:
| > I just came across this (https://gist.github.com/1208215):
| >
| > import sys
| > import ctypes
| > pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5))
| > five = ctypes.cast(id(5), pyint_p)
| > print(2 + 2 == 5) # False
| > five.contents[five.contents[:].index(5)] = 4
| > print(2 + 2 == 5) # True (must be sufficiently large values of 2 there...)
| >
| > Heh. The author is apparently anonymous, I guess for good reason.
|
| Probably just nostalgic for old Fortran, which, supposedly, allowed you
| to change the values of literals by passing them to a function by
| reference and then modifying the value.

Yeah, I was thinking that too. Because all parameters were pass-by-reference
in early fortran IIRC. You could, for example, set pi to 3.
--
Cameron Simpson <(E-Mail Removed)>

If I have seen farther than others, it is because I was standing on the
shoulders of giants. - Isaac Newton

If I have not seen as far as others, it is because giants were standing on my
shoulders. - Hal Abelson

In computer science, we stand on each other's feet. - Brian K. Reed
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments