R history: Why 'L; in suffix character ‘L’ for integer constants?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

R history: Why 'L; in suffix character ‘L’ for integer constants?

Henrik Bengtsson-5
I'm just curious (no complaints), what was the reason for choosing the
letter 'L' as a suffix for integer constants?  Does it stand for
something (literal?), is it because it visually stands out, ..., or no
specific reason at all?

/Henrik

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R history: Why 'L; in suffix character ‘L’ for integer constants?

Serguei Sokol
Le 16/06/2017 à 17:54, Henrik Bengtsson a écrit :
> I'm just curious (no complaints), what was the reason for choosing the
> letter 'L' as a suffix for integer constants?  Does it stand for
> something (literal?), is it because it visually stands out, ..., or no
> specific reason at all?
My guess is that it is inherited form C "long integer" type (contrary to "short integer" or simply "integer")
https://en.wikipedia.org/wiki/C_data_types

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R history: Why 'L; in suffix character ‘L’ for integer constants?

Yihui Xie-2
Yeah, that was what I heard from our instructor when I was a graduate
student: L stands for Long (integer).

Regards,
Yihui
--
https://yihui.name


On Fri, Jun 16, 2017 at 11:00 AM, Serguei Sokol <[hidden email]> wrote:

> Le 16/06/2017 à 17:54, Henrik Bengtsson a écrit :
>>
>> I'm just curious (no complaints), what was the reason for choosing the
>> letter 'L' as a suffix for integer constants?  Does it stand for
>> something (literal?), is it because it visually stands out, ..., or no
>> specific reason at all?
>
> My guess is that it is inherited form C "long integer" type (contrary to
> "short integer" or simply "integer")
> https://en.wikipedia.org/wiki/C_data_types

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R history: Why 'L; in suffix character ‘L’ for integer constants?

R devel mailing list
But R "integers" are C "ints", as opposed to S "integers", which are C
"long ints".  (I suppose R never had to run on ancient hardware with 16 bit
ints.)

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Jun 16, 2017 at 10:47 AM, Yihui Xie <[hidden email]> wrote:

> Yeah, that was what I heard from our instructor when I was a graduate
> student: L stands for Long (integer).
>
> Regards,
> Yihui
> --
> https://yihui.name
>
>
> On Fri, Jun 16, 2017 at 11:00 AM, Serguei Sokol <[hidden email]>
> wrote:
> > Le 16/06/2017 à 17:54, Henrik Bengtsson a écrit :
> >>
> >> I'm just curious (no complaints), what was the reason for choosing the
> >> letter 'L' as a suffix for integer constants?  Does it stand for
> >> something (literal?), is it because it visually stands out, ..., or no
> >> specific reason at all?
> >
> > My guess is that it is inherited form C "long integer" type (contrary to
> > "short integer" or simply "integer")
> > https://en.wikipedia.org/wiki/C_data_types
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R history: Why 'L; in suffix character ‘L’ for integer constants?

Peter Dalgaard-2
Wikipedia claims that C ints are still only guaranteed to be at least 16 bits, and longs are at least 32 bits. So no, R's integers are long.

-pd

> On 16 Jun 2017, at 20:20 , William Dunlap via R-devel <[hidden email]> wrote:
>
> But R "integers" are C "ints", as opposed to S "integers", which are C
> "long ints".  (I suppose R never had to run on ancient hardware with 16 bit
> ints.)
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Fri, Jun 16, 2017 at 10:47 AM, Yihui Xie <[hidden email]> wrote:
>
>> Yeah, that was what I heard from our instructor when I was a graduate
>> student: L stands for Long (integer).
>>
>> Regards,
>> Yihui
>> --
>> https://yihui.name
>>
>>
>> On Fri, Jun 16, 2017 at 11:00 AM, Serguei Sokol <[hidden email]>
>> wrote:
>>> Le 16/06/2017 à 17:54, Henrik Bengtsson a écrit :
>>>>
>>>> I'm just curious (no complaints), what was the reason for choosing the
>>>> letter 'L' as a suffix for integer constants?  Does it stand for
>>>> something (literal?), is it because it visually stands out, ..., or no
>>>> specific reason at all?
>>>
>>> My guess is that it is inherited form C "long integer" type (contrary to
>>> "short integer" or simply "integer")
>>> https://en.wikipedia.org/wiki/C_data_types
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R history: Why 'L; in suffix character ‘L’ for integer constants?

R devel mailing list
"Writing R Extensions" says "int":

R storage mode  C type  FORTRAN type
logical  int*  INTEGER
integer  int*  INTEGER
double  double*  DOUBLE PRECISION
complex  Rcomplex*  DOUBLE COMPLEX
character  char**  CHARACTER*255
raw  unsigned char*  none

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Jun 16, 2017 at 11:53 AM, peter dalgaard <[hidden email]> wrote:
>
> Wikipedia claims that C ints are still only guaranteed to be at least 16
bits, and longs are at least 32 bits. So no, R's integers are long.
>
> -pd
>
> > On 16 Jun 2017, at 20:20 , William Dunlap via R-devel <
[hidden email]> wrote:
> >
> > But R "integers" are C "ints", as opposed to S "integers", which are C
> > "long ints".  (I suppose R never had to run on ancient hardware with 16
bit

> > ints.)
> >
> > Bill Dunlap
> > TIBCO Software
> > wdunlap tibco.com
> >
> > On Fri, Jun 16, 2017 at 10:47 AM, Yihui Xie <[hidden email]> wrote:
> >
> >> Yeah, that was what I heard from our instructor when I was a graduate
> >> student: L stands for Long (integer).
> >>
> >> Regards,
> >> Yihui
> >> --
> >> https://yihui.name
> >>
> >>
> >> On Fri, Jun 16, 2017 at 11:00 AM, Serguei Sokol <[hidden email]
>
> >> wrote:
> >>> Le 16/06/2017 à 17:54, Henrik Bengtsson a écrit :
> >>>>
> >>>> I'm just curious (no complaints), what was the reason for choosing
the
> >>>> letter 'L' as a suffix for integer constants?  Does it stand for
> >>>> something (literal?), is it because it visually stands out, ..., or
no
> >>>> specific reason at all?
> >>>
> >>> My guess is that it is inherited form C "long integer" type (contrary
to

> >>> "short integer" or simply "integer")
> >>> https://en.wikipedia.org/wiki/C_data_types
> >>
> >> ______________________________________________
> >> [hidden email] mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: [hidden email]  Priv: [hidden email]
>
>
>
>
>
>
>
>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R history: Why 'L; in suffix character ‘L’ for integer constants?

Jim Hester
The relevant sections of the C standard are
http://c0x.coding-guidelines.com/5.2.4.2.1.html, which specifies that C
ints are only guaranteed to be 16 bits, C long ints at least 32 bits in
size, as Peter mentioned. Also http://c0x.coding-guidelines.com/6.4.4.1.html
specifies l or L as the suffix for a long int constants.

However R does define integers as `int` in it's source code, so use of L is
not strictly correct if a compiler uses 16 bit int types. I guess this
ambiguity is why the `int32_t` typedef exists.

On Fri, Jun 16, 2017 at 3:01 PM, William Dunlap via R-devel <
[hidden email]> wrote:

> "Writing R Extensions" says "int":
>
> R storage mode  C type  FORTRAN type
> logical  int*  INTEGER
> integer  int*  INTEGER
> double  double*  DOUBLE PRECISION
> complex  Rcomplex*  DOUBLE COMPLEX
> character  char**  CHARACTER*255
> raw  unsigned char*  none
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Fri, Jun 16, 2017 at 11:53 AM, peter dalgaard <[hidden email]> wrote:
> >
> > Wikipedia claims that C ints are still only guaranteed to be at least 16
> bits, and longs are at least 32 bits. So no, R's integers are long.
> >
> > -pd
> >
> > > On 16 Jun 2017, at 20:20 , William Dunlap via R-devel <
> [hidden email]> wrote:
> > >
> > > But R "integers" are C "ints", as opposed to S "integers", which are C
> > > "long ints".  (I suppose R never had to run on ancient hardware with 16
> bit
> > > ints.)
> > >
> > > Bill Dunlap
> > > TIBCO Software
> > > wdunlap tibco.com
> > >
> > > On Fri, Jun 16, 2017 at 10:47 AM, Yihui Xie <[hidden email]> wrote:
> > >
> > >> Yeah, that was what I heard from our instructor when I was a graduate
> > >> student: L stands for Long (integer).
> > >>
> > >> Regards,
> > >> Yihui
> > >> --
> > >> https://yihui.name
> > >>
> > >>
> > >> On Fri, Jun 16, 2017 at 11:00 AM, Serguei Sokol <
> [hidden email]
> >
> > >> wrote:
> > >>> Le 16/06/2017 à 17:54, Henrik Bengtsson a écrit :
> > >>>>
> > >>>> I'm just curious (no complaints), what was the reason for choosing
> the
> > >>>> letter 'L' as a suffix for integer constants?  Does it stand for
> > >>>> something (literal?), is it because it visually stands out, ..., or
> no
> > >>>> specific reason at all?
> > >>>
> > >>> My guess is that it is inherited form C "long integer" type (contrary
> to
> > >>> "short integer" or simply "integer")
> > >>> https://en.wikipedia.org/wiki/C_data_types
> > >>
> > >> ______________________________________________
> > >> [hidden email] mailing list
> > >> https://stat.ethz.ch/mailman/listinfo/r-devel
> > >
> > >       [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > [hidden email] mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> > --
> > Peter Dalgaard, Professor,
> > Center for Statistics, Copenhagen Business School
> > Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> > Phone: (+45)38153501
> > Office: A 4.23
> > Email: [hidden email]  Priv: [hidden email]
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R history: Why 'L; in suffix character ‘L’ for integer constants?

Prof Brian Ripley
On 16/06/2017 20:37, Jim Hester wrote:
> The relevant sections of the C standard are
> http://c0x.coding-guidelines.com/5.2.4.2.1.html, which specifies that C

There is more than one C standard, but that is none of them.

> ints are only guaranteed to be 16 bits, C long ints at least 32 bits in
> size, as Peter mentioned. Also http://c0x.coding-guidelines.com/6.4.4.1.html
> specifies l or L as the suffix for a long int constants.
>
> However R does define integers as `int` in it's source code, so use of L is
> not strictly correct if a compiler uses 16 bit int types. I guess this
> ambiguity is why the `int32_t` typedef exists.

However, R checks that the compiler uses 32-bit ints in its build
(configure and src/main/arithmetic.c) and documents that in R-admin .
In any case, the C standard does not apply to the R language.

Also, int32_t

- postdates R (it was introduced in C99, a few OSes having it earlier)
- is optional in the C99 and C11 standards (§7.20.1.1 in C11).


>
> On Fri, Jun 16, 2017 at 3:01 PM, William Dunlap via R-devel <
> [hidden email]> wrote:
>
>> "Writing R Extensions" says "int":
>>
>> R storage mode  C type  FORTRAN type
>> logical  int*  INTEGER
>> integer  int*  INTEGER
>> double  double*  DOUBLE PRECISION
>> complex  Rcomplex*  DOUBLE COMPLEX
>> character  char**  CHARACTER*255
>> raw  unsigned char*  none
>>
>> Bill Dunlap
>> TIBCO Software
>> wdunlap tibco.com
>>
>> On Fri, Jun 16, 2017 at 11:53 AM, peter dalgaard <[hidden email]> wrote:
>>>
>>> Wikipedia claims that C ints are still only guaranteed to be at least 16
>> bits, and longs are at least 32 bits. So no, R's integers are long.
>>>
>>> -pd
>>>
>>>> On 16 Jun 2017, at 20:20 , William Dunlap via R-devel <
>> [hidden email]> wrote:
>>>>
>>>> But R "integers" are C "ints", as opposed to S "integers", which are C
>>>> "long ints".  (I suppose R never had to run on ancient hardware with 16
>> bit
>>>> ints.)
>>>>
>>>> Bill Dunlap
>>>> TIBCO Software
>>>> wdunlap tibco.com
>>>>
>>>> On Fri, Jun 16, 2017 at 10:47 AM, Yihui Xie <[hidden email]> wrote:
>>>>
>>>>> Yeah, that was what I heard from our instructor when I was a graduate
>>>>> student: L stands for Long (integer).
>>>>>
>>>>> Regards,
>>>>> Yihui
>>>>> --
>>>>> https://yihui.name
>>>>>
>>>>>
>>>>> On Fri, Jun 16, 2017 at 11:00 AM, Serguei Sokol <
>> [hidden email]
>>>
>>>>> wrote:
>>>>>> Le 16/06/2017 à 17:54, Henrik Bengtsson a écrit :
>>>>>>>
>>>>>>> I'm just curious (no complaints), what was the reason for choosing
>> the
>>>>>>> letter 'L' as a suffix for integer constants?  Does it stand for
>>>>>>> something (literal?), is it because it visually stands out, ..., or
>> no
>>>>>>> specific reason at all?
>>>>>>
>>>>>> My guess is that it is inherited form C "long integer" type (contrary
>> to
>>>>>> "short integer" or simply "integer")
>>>>>> https://en.wikipedia.org/wiki/C_data_types
>>>>>
>>>>> ______________________________________________
>>>>> [hidden email] mailing list
>>>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>>
>>>>        [[alternative HTML version deleted]]
>>>>
>>>> ______________________________________________
>>>> [hidden email] mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>> --
>>> Peter Dalgaard, Professor,
>>> Center for Statistics, Copenhagen Business School
>>> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>>> Phone: (+45)38153501
>>> Office: A 4.23
>>> Email: [hidden email]  Priv: [hidden email]
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>          [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>


--
Brian D. Ripley,                  [hidden email]
Emeritus Professor of Applied Statistics, University of Oxford

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R history: Why 'L; in suffix character‘L’ for integer constants?

Dirk Eddelbuettel

On 17 June 2017 at 06:40, Prof Brian Ripley wrote:
| Also, int32_t
|
| - postdates R (it was introduced in C99, a few OSes having it earlier)
| - is optional in the C99 and C11 standards (§7.20.1.1 in C11).

Thanks for the C99 reference. Do you happen to know when it was added to C++?

For the record, it became fairly common with C++ world in the early 'naughts'
to abstract hardware and OS sizes away when more code was going from being
used only on 32-bit OSs to also being used on 64-bit OSs.  And being able to
specify the width of integers was a big help for portable code.

Dirk

--
http://dirk.eddelbuettel.com | @eddelbuettel | [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel