erlang的abstract_code代码

本文介绍了使用Erlang进行编程的基本过程,包括创建模块、编译和运行带有调试信息的程序。通过一个简单的示例,展示了如何在Erlang中输出字符串helloworld,并获取编译后的抽象代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在看了霸爷的[url=http://blog.yufeng.info/archives/76]erlang的abstract code[/url]之后,自己动手实验了一下,效果如下:

[liufan@liufan abstract_code]$ erl -s hello -s erlang halt
Erlang R16B01 (erts-5.10.2) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

"hello world"
[liufan@liufan abstract_code]$ cat hello.erl
-module(hello).

-export([start/0]).

start() ->
io:format("~p~n", ["hello world"]).
[liufan@liufan abstract_code]$ erlc +debug_info hello.erl
[liufan@liufan abstract_code]$ erl
Erlang R16B01 (erts-5.10.2) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.2 (abort with ^G)
1> rp(beam_lib:chunks(hello, [abstract_code])).
{ok,{hello,
[{abstract_code,
{raw_abstract_v1,
[{attribute,1,file,{"hello.erl",1}},
{attribute,1,module,hello},
{attribute,3,export,[{start,0}]},
{function,5,start,0,
[{clause,5,[],[],
[{call,6,
{remote,6,{atom,6,io},{atom,6,format}},
[{string,6,"~p~n"},
{cons,6,
{string,6,"hello world"},
{nil,6}}]}]}]},
{eof,7}]}}]}}
ok
2>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值