[erlang-questions] Otp.NET: It would be nice to have seamless string support

Roessner, Silvester silvester.roessner@REDACTED
Wed Apr 29 08:11:57 CEST 2009


(sorry for the former incomplete e-mail - I hit enter by accident)

I think it would be usefull to have a real Otp.Erlang.List object
that combines Otp.Erlang.List and Otp.Erlang.String.

This object should have a constructor String(string S)
and a methode stringValue().

The reason why I think this is sensible:

I run into a problem while I tried to send Otp.Erlang.String 
with length > 64k from a OTP.Net node to a native Erlang node.
The Erlang node only received a cut string, not the full one.

The cause of this trouble is the strong adherence of OTP.Net 
to the external term format.

The Erlang node sends a list in an external term "STRING_EXT"
when the list length < 64k and all list entries are integers 
in the range 0..255

But it sends a list as an external term "LIST_EXT" otherwise.

OTP.Net has implemented Otp.Erlang.String but this is not a 
real Erlang type only an external term.

When I use OTP.Net to receive from or send strings to another 
node I have to manually distinguish between these two cases.

                        Otp.Erlang.String S =
                        Payload = S.stringValue();
                    catch (InvalidCastException)
                        Otp.Erlang.List List =
                        Payload = stringValue(List);

        private string stringValue(Otp.Erlang.List L)
            System.Text.StringBuilder s = new
            int _arity = L.Length;
            Otp.Erlang.Long E_Char;
			for (int i = 0; i < _arity; i++)
                                E_Char =
			return s.ToString();


                    Otp.Erlang.Object[] Message = new
                    Message[0] = new Otp.Erlang.Int(L);

                    if (L < 65000) 
                        Message[1] = new Otp.Erlang.String(Payload);
                        Otp.Erlang.String Test = new
                        int LL = Test.stringValue().Length;
                        new Otp.Erlang.List(
                        Message[1] = toList(Payload);
                    Box.send(Other, new Tuple(Message));

        private Otp.Erlang.List toList(string S)
            int _arity = S.Length;
            Otp.Erlang.Object[] Longs = new Otp.Erlang.Object[_arity];

            for (int i = 0; i < _arity; i++)
                Longs[i] = new Otp.Erlang.Long(S[i]);

            return new Otp.Erlang.List(Longs);
This message is intended for a particular addressee only and
may contain business or company secrets. If you have received
this email in error, please contact the sender and delete the
message immediately. Any use of this email, including saving,
publishing, copying, replication or forwarding of the message
or the contents is not permitted.

More information about the erlang-questions mailing list