You should have read Yariv's recless blog, a nice blog talking about how to make record accessing simple.
Recless is a static type inferring record parse transform, that means, as described in Yariv's blog:
one main restriction in Recless’s type inference algorithm: function parameters must indicate their record types for type inference to work on them. For instance, this won’t work:
get_name(Person) -> Person.name.
Instead, you must write this:
get_name(Person = #person{}) -> Person.name.
How about a dynamic record inferring solution? I got some idea that was also inspired from my friend Haobo. As I'm familiar with Erlang AST tree when developing ErlyBird, I took a try and got some good result. I named it recbird.
The magic behind recbird is, it parses the Erlang AST tree, and adds some setter/getter functions for each record's field. Then, at runtime, it will detect the first element of record var, and thus knows which setter/getter function should be redirected, and call it.
It just works now, with none limits, you can write R.a.b.c and R.a.b.c = Sth almost every where.
Notice: There may be some bugs.
The perfomance is also reasonable, for example, when you do R.a.b = 'yes' 1,000,000 times, the original Erlang record syntax takes about 300ms in my machine, the recbird is about 310ms. When you run it 10,000,000 times, the recbird is about 150% more time costed than original Erlang record accessing.
The recbird's source code can be got at:
recbird.erl
To use it, compile it, include compiled recbird.beam under your code path, add
-compile({parse_transform, recbird}).
in your source file.
分享到:
相关推荐
erlang_23.0.2-1版本 centos7 64bit esl-erlang_23.0.2-1_centos_7_amd64.rpm
esl-erlang_17.3-1~centos~6_amd64.rpm esl-erlang_17.3-1~centos~6_amd64.rpm
esl-erlang_24.2.1-1_centos_7_amd64.rpm
linux服务器安装rabbitMQ,首选需要必备语言erlang,再次提供一个解压包
esl-erlang-20.1-1.x86_64只适用于Centos7; 安装命令:rpm -ivh --force esl-erlang-20.1-1.x86_64.rpm
此rpm包是专门为部署rabbitmq-server而准备的所需的包,centos7.5系统,相关博客详见https://blog.csdn.net/baidu_38432732/article/details/105813004
esl-erlang_25.0.3-1_centos_7_amd64.rpm erlang_25.0.3-1 rpm用于rabitmq基础环境安装
RabbitMQ运行需要erlang环境,erlang22.1是windows64位的,适合RabbitMQ 3.7.*-3.8.*,官网下载速度极慢,下了很久才下下来,在这里分享给有需要的同学。
esl-erlang_16.b.3-2~centos~6_amd64.rpm
rabbitmq-server-3.8.2.exe ErLang_otp_win64_22.2.exe window系统RabbitMQ安装
esl-erlang_19.0~centos~6_amd64.rpm
这个erlang23.0版本,根据rabbitMQ官网的介绍,可以和下面这几个版本的rabbitMQ配合使用: 3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 其他版本的rabbit,请移步其他资源下载
NULL 博文链接:https://ZacMa.iteye.com/blog/1976833
Server Metaprogramming Ruby-Pyton-Groovy-Haskell-Erlang.pdf
esl-erlang_23.0和rabbitmq-3.8.4windows版本 直接下载安装就行,可以直接下载就可安装,非常的方便 ,欢迎大家下载 注意事项: 1. Erlang版本和RabbitMQ版本要配套 (Erlang23.0, RabbitMQ3.8.4) 2. amd芯片请乖乖...
esl-erlang_19.3_osx_10.10_amd64.dmg
esl-erlang-compat-R14B-1.el6.noarch.rpm
esl-erlang_17.0-1~centos~6_amd64.rpm
基于Erlang的即时通信系统并发性能研究,杨杰,张淼,为了提升即时通信服务的并发性能以及鲁棒性,以适应日益庞大的网络用户量,本文根据Erlang语言的特性,设计了特殊的进程监管机制以
erlang centos7安装包,安装rabbitmq依赖的安装包,rpm安装包