[Rd] Parser bug? A comma too much.

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Tue Sep 20 09:22:06 CEST 2022


Hello,

A bit late but thanks for the extra explanation.

Rui Barradas

Às 16:00 de 16/09/2022, peter dalgaard escreveu:
> As a general matter, empty arguments are allowed and are used meaningfully in some contexts, notably A[i,], which is syntactic sugarcoating of "["(A,i,).
> 
> I.e., these are different:
> 
>> "["(Sigma,2,) # 2nd row
> [1] 0.077 0.168
>> "["(Sigma,2) # 2nd element
> [1] 0.077
> 
> 
> It is somewhat rare to have an empty last argument, intermediate ones are more common:
> 
>> seq(0,1,,5)
> [1] 0.00 0.25 0.50 0.75 1.00
> 
> -pd
> 
> 
>> On 16 Sep 2022, at 16:33 , Rui Barradas <ruipbarradas using sapo.pt> wrote:
>>
>> Hello,
>>
>> Why doesn't the comma throw an error?
>>
>>
>> plot(1:5,)    # works, no complaints
>>
>>
>> Shouldn't this be considered a bug? I would expect the parser to at least give a warning.
>>
>>
>> sessionInfo()
>> R version 4.2.1 (2022-06-23 ucrt)
>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>> Running under: Windows 10 x64 (build 22000)
>>
>> Matrix products: default
>>
>> locale:
>> [1] LC_COLLATE=Portuguese_Portugal.utf8 LC_CTYPE=Portuguese_Portugal.utf8
>> [3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C
>> [5] LC_TIME=Portuguese_Portugal.utf8
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>> loaded via a namespace (and not attached):
>> [1] compiler_4.2.1
>>
>>
>> Rui Barradas
>>
>> ______________________________________________
>> R-devel using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>



More information about the R-devel mailing list