Sometimes inconsistent formatting of integer numbers (ending with an L char)

10 views
Skip to first unread message

marQIsoft

unread,
Aug 11, 2016, 5:10:44 PM8/11/16
to Tinn-R Editor
Hi guys,

My today's request is not very important, but it would be nice to improve this aspect of code 'highlighting' of R code in Tinn-R.
Although integers are not defined explicitly very frequently (with the 'L' suffix character), I found this is good practice, so I have some 12345L -like values in my codes.
But Tinn-R does not color these like numbers. Why should the (default) blue color be only for "float" numbers?
In my view, it would be interesting to color integers as well, so that we may find them more easily when taking a look at the code.

#Example code with sometimes strange formatting of numbers,
# in particular integer numbers...


a
= 100000 #ok
b
= 100000L #here it's an explicit integer-class number; why is its color different?
d
= 1e2L #even if it's not the right way to write it, this is also accepted as an integer by R
e
= 1.23456 #ok
f
= .123456 #ok
g
= .123L #not ok, but: it would be a nice feature that Tinn-R highlights as 'error-prone' such not-round real numbers followed by 'L' integer-maker symbol...
h
= range(a, b, d, 20, 1000L,100L,100,100L, 50L, 50)
#This last case (h) is very strange: some integer numbers were black while some
# others were blue: why not all blue?... but then, after some minor changes to
# other parts of the code, all numbers became blue. But even if the 'all blue'
# scenario is what I would prefer, why is it already occurring? Indeed, the
# currently normal formatting color for integer numbers like 1000L is black.

(funny fact: the Google Groups code highlighting colors all numbers, both reals and integers, with a common color. That's what we would like in Tinn-R... for numbers.)

So, if you agree with the above, could you make the appropriate changes in Tinn-R?
Thanks!

Marc (alias marQIsoft)

marQIsoft

unread,
Aug 12, 2016, 3:53:55 PM8/12/16
to Tinn-R Editor
Further examples to better understand this minor but existing issue:

rep_len(1L:5L, 100) #Why are integer numbers in green?
rep_len
(1L:5L, 1001L) #Why are integer numbers in green?
c
(1L:5L, 1001L) #Why are integer numbers in green?
1L:5L + 1001L #Why are integer numbers in black?
1L:5L 1001L #Why are int. nbs. in black (left part) then gray ~comment (right)?
1000 1000 #Ok, these real numbers are in blue as they should be.
(Remark: The comments above are for the highlighting auto-formatting within Tinn-R, not here in Google Groups...)

Marc

Jose Claudio Faria

unread,
Sep 18, 2016, 8:16:13 AM9/18/16
to marQIsoft, Tinn-R Editor
Hello Marc,

His remarks have been added to the TODO list of the project.
We appreciate the attention to alert us to these problems.

Best,
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
Jose Claudio Faria
Estatistica
UESC/DCET/Brasil
joseclaudio.faria at gmail.com
Telefones:
55(73)3680.5545 - UESC
55(73)99966.9100 - VIVO
55(73)99100.7351 - TIM
55(73)98817.6159 - OI
55(73)98129.9942 - CLARO
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
> --
> You received this message because you are subscribed to the Google Groups
> "Tinn-R Editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to tinn-r+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Marc Laurencelle

unread,
Oct 5, 2016, 4:01:07 PM10/5/16
to Jose Claudio Faria, Tinn-R Editor
Hi Jose,

That's excellent! Numbers are now recognized and highlighted adequately!

There is, however, a subtle point I would like to comment: the way Numbers (i.e. integer values) are distinguished from Floats (i.e. real values) for highlighting, is slightly different from the way R does interpret numeric values in the code when assigning to variables. In R, a code with a number without decimal, e.g. "12345", will be assigned as a "numeric" class, i.e. ~float; to be recognized as integer, the user must add the "L" suffix: "12345L". But in Tinn-R, values like 12345 are interpreted and highlighted as "Number".

In current version of Tinn-R, all of these are highlighted as "Float": 1E5, 1.234, 1.234E6, 1.2e-10, 1.234e+10... and it's right.
But the following are highlighted as "Number": 1, 123, 0, while they should rather be "Float" (because "numeric" in R).

Could you modify the criteria for Number vs. Float for the R Highlighters in Tinn-R, so that it follows the same interpretation as in R? This way, I'll be able to locate integer values within my codes with an easily visible highlighter such as with the Underlined option.

You may even add a third category for highlighting numeric values in Tinn-R Editor: that would be a "Unclear integer / float", for values with no decimal, nor any "L" suffix. This would help "rigorous" programmers to locate the parts of the code where the type of number is unclear: for a float, the user should change for example from 123 to 123.0... whereas for an integer value, he would modify 123 to 123L. I would use a red color for hightlighting such numbers in my code, although the default should remain "same appearance for all numbers, real / integer / unclear", to keep it simple for standard users.

Thanks again.

Marc


Reply all
Reply to author
Forward
0 new messages