Skip to content

Monthly Archives: December 2009

Erlang Native Implemented Functions – NIF

07-Dec-09

Erlang has long had a love hate relationship with external code. There is now “experimental” code in the latest R13B03 release that has support for what they are calling Native Implemented Functions. It is a very basic interface with only 4 functions required to be implemented and a struct and macros for defining your public [...]

Ternary Like Operation in Erlang

02-Dec-09

I have to parse the TXT records from DNS responses for my inet_mdns project. The valid key values pairs look like one of the following three formats: “key=value” “key=” ( key with an empty/no value ) “key” means the same thing as “key=true” so in Java I would write something like. public String processKeyValue(final String [...]

Refactoring my Erlang code to be more functional

01-Dec-09

Here is what my procedural “C/C++/Java” style syntax paradigm mind created, it worked but it isn’t as functional as I think it should be. Here is what I came up with. % process the dns resource records list process_dnsrec(_Sub,{error,E}) ->     io:format("Error: ~p~n", [E]); process_dnsrec(Sub,{ok,#dns_rec{anlist=Responses}}) ->     process_dnsrec1(Sub,Responses). % test to see if a dns_rr.domain is subscribed [...]