[erlang-questions] What is the best way to parse complex erlang terms in port drivers?
Sat Jun 9 09:08:32 CEST 2012
Thanks a lot! Things have become slightly clearer. I have been looking for exactly such recommendations.
The problem is that on the native-code side I have to translate erlang terms into a rather complex ?++ object that encapsulates the complexity of an underlying protocol format. It seems there is no alternatives to using ei in such a case.
The ability to create a binary object in erlang and to use driver just to pass it through to the underlying level is pretty awesome.
From: Björn-Egil Dahlberg [mailto:wallentin.dahlberg@REDACTED]
Sent: Saturday, June 09, 2012 12:10 AM
To: Zhemzhitsky Sergey
Cc: Richard O'Keefe; erlang-questions@REDACTED
Subject: Re: [erlang-questions] What is the best way to parse complex erlang terms in port drivers?
First, I would like to say.:Yes, the erl_interface documentation is lacking in details and examples.
Secondly, I would like to reframe your question. Should I use erl_interface to communicate with my port driver in the first place? Many examples point to that fact but I would disagree.
erl_interface, (ei), should be used for c-nodes where we want to talk to our c-program over erlang distribution. When I want my c-program to simulate an erlang node. This is, I think, a rare case though.
In most situations I would construct a packet protocol instead and handle this protocol on the erlang side with bitsyntax. Handling "c-data" in erlang is much easier than using erlang terms in c. Look at efile_drv and inet_drv, none of those use erl_interface. The protocol becomes far simpler and probably faster.
We have only one other case where it makes sense to encode and decode terms in c and that is when our data are in the erlang process heap, i.e. when we use NIFs. But, in this case we have an entirely different API so we wouldn't use ei here either.
So, while I agree that ei could be better documented, I question if you really need it. I think it complicates more things than it solves.
The information contained in this message may be privileged and conf idential and protected from disclosure. If you are not the original intended recipient, you are hereby notified that any review, retransmission, dissemination, or other use of, or taking of any action in reliance upon, this information is prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and delete it from your computer. Thank you for your cooperation. Troika Dialog, Russia.
If you need assistance please contact our Contact Center (+7495) 258 0500 or go to www.troika.ru/eng/Contacts/system.wbp
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions