[Rd] Rserve setSEXP command

Chris Burke cburke at jsoftware.com
Mon Dec 26 21:43:47 CET 2005


Simon Urbanek wrote:
>> Can any valid SEXP expression be given in the setSEXP command?
>>
>> I tried to send a numeric matrix by including the dim attribute  with
>> the data, but get an error code 68 (some parameters are  invalid). Is
>> the dim attribute not supported by setSEXP? If so,  does this mean a
>> matrix should be sent as a list, then a dim  command sent in a second
>> step?
> 
> 
> It's a combination of a bug and missing feature. The bug is that the 
> attribute of an expression is not decoded at all. The missing feature 
> is that (dotted-pair) lists are not supported in decode, so you can't 
> pass an attribute anyway, because they are stored in dotted-pair  lists.
> So, for now, yes, you have to assign the names in a separate  step -
> I'll need to fix that ... I'll keep you posted.

Hi Simon

Thanks for the quick response.

A couple of other things I noticed:

1. It would be useful to support the complex datatype. I suspect this
would be straightforward for Rserve and it would be up to the client to
make proper use of it.

2. The documentation and behaviour when sending character strings could
be improved. For example, suppose the character string is 'abcde'. You
need to send the length, but is the length 5 (=number of characters), 6
(5 + the zero character), or 8 (actual length of transmitted data
rounded to 4 byte boundary?

I had expected it to be 8, which is the length of data the programmer
needs to pick up, before moving on to the next block. The character
string would then be read up to the first 0. Actually, if you give a len
of 8, then:

  CMD_setSEXP 'var';'abcde'

assigns the value as in:

  var=c("abcde","","")

This means that the two additional zeros that are padding, are
interpreted as empty strings. So in practice, a len of 6 is needed (i.e.
length of string plus the zero character).

It is probably worth documenting which is correct, and also, for
zero-terminated strings, always reading them up to the first zero only,
and discarding the rest.

Incidentally, this is for the XT_STR expression. For DT_STR, lengths of
either 6 or 8 work correctly.

Great program, by the way.

Chris



More information about the R-devel mailing list