From hp@ge@ @ending from fredhutch@org  Sun Aug 26 05:07:04 2018
From: hp@ge@ @ending from fredhutch@org (=?UTF-8?B?SGVydsOpIFBhZ8Oocw==?=)
Date: Sat, 25 Aug 2018 20:07:04 -0700
Subject: [Rd] Where does L come from?
In-Reply-To: <23425.51416.778722.954108@rob.eddelbuettel.com>
References: <CABdHhvGa67SEpGkCffGpTu6P+u+0sKj-XOMP0ZNTGp0S6RmQqA@mail.gmail.com>
 <96A60DDD-DD37-48FF-BF43-94B1821A3E7F@me.com>
 <CAFDcVCQ91xLdHDRoFE1iLCxEc=cOMRg4YMfHhF++pjadbvUT-A@mail.gmail.com>
 <CAN_1p9z=CKznjkZ-_Gwu5pGV6LX1oUKaKKnQBw-hqt6h0C1O6Q@mail.gmail.com>
 <23425.35688.465437.842641@rob.eddelbuettel.com>
 <6ae89d21-0a0d-805a-e8db-9de20c42a019@fredhutch.org>
 <23425.51416.778722.954108@rob.eddelbuettel.com>
Message-ID: <90f3fe0f-1192-2b24-b356-90fd072b6bf6@fredhutch.org>



On 08/25/2018 02:23 PM, Dirk Eddelbuettel wrote:
> 
> On 25 August 2018 at 13:49, Herv? Pag?s wrote:
> | The choice of the L suffix in R to mean "R integer type", which
> | is mapped to the "int" type at the C level, and NOT to the "long int"
> | type, is really unfortunate as it seems to be misleading and confusing
> | a lot of people.
> 
> The point I was trying to make in what you quote below is that the L may come
> from a time when int and long int were in fact the same on most relevant
> architectures. And it is hardly R's fault that C was allowed to change.
> 
> Also, it hardly matters given that R has precisely one integer type so I am
> unsure where you see the confusion between long int and int.
>   
> | The fact that nowadays "int" and "long int" have the same size on most
> | platforms is only anecdotal here.
> |
> | Just my 2 cents.
> 
> Are you sure?
> 
>    R> Rcpp::evalCpp("sizeof(long int)")
>    [1] 8
>    R> Rcpp::evalCpp("sizeof(int)")
>    [1] 4
>    R>

My bad, it's only the same on Windows. My point is that the discussion
about the size of int vs long int is only a distraction here. The 
important bit is that 10L in R is represented by 10 in C, which is an
int, not by 10L, which is a long int. Could hardly be more confusing.

H.


> 
> Dirk
> 
> | H.
> |
> | On 08/25/2018 10:01 AM, Dirk Eddelbuettel wrote:
> | >
> | > On 25 August 2018 at 09:28, Carl Boettiger wrote:
> | > | I always thought it meant "Long" (I'm assuming R's integers are long
> | > | integers in C sense (iirrc one can declare 'long x', and it being common to
> | > | refer to integers as "longs"  in the same way we use "doubles" to mean
> | > | double precision floating point).  But pure speculation on my part, so I'm
> | > | curious!
> | >
> | > It does per my copy (dated 1990 !!) of the 2nd ed of Kernighan & Ritchie.  It
> | > explicitly mentions (sec 2.2) that 'int' may be 16 or 32 bits, and 'long' is
> | > 32 bit; and (in sec 2.3) introduces the I, U, and L labels for constants.  So
> | > "back then when" 32 bit was indeed long.  And as R uses 32 bit integers ...
> | >
> | > (It is all murky because the size is an implementation detail and later
> | > "essentially everybody" moved to 32 bit integers and 64 bit longs as the 64
> | > bit architectures became prevalent.  Which is why when it matters one should
> | > really use more explicit types like int32_t or int64_t.)
> | >
> | > Dirk
> | >
> |
> | --
> | Herv? Pag?s
> |
> | Program in Computational Biology
> | Division of Public Health Sciences
> | Fred Hutchinson Cancer Research Center
> | 1100 Fairview Ave. N, M1-B514
> | P.O. Box 19024
> | Seattle, WA 98109-1024
> |
> | E-mail: hpages at fredhutch.org
> | Phone:  (206) 667-5791
> | Fax:    (206) 667-1319
> 

-- 
Herv? Pag?s

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



[Rd] Where does L come from?
=?UTF-8?B?SGVydsOpIFBhZ8Oocw==?=