57 apply(Fun, Args) ->
58 apply(Fun,Args).
59
60 apply(Mod, Name, Args) ->
61 apply(Mod, Name, Args).
上面代码是erlang.erl文件里看到的。这里aplly/3方法里面又调用一次apply/3 请问是什么意思
老大: 在虚拟机里面实现的
langzhe: 谢谢
erlang.erl代码编译的时候 进行了特殊编译?所以再调用时候 不会默认调用erlang:apply/3?
老大: 恩
需要进一步 看看是怎么编译的?
来自http://erlang.2086793.n4.nabble.com/Erlang-about-quot-apply-quot-function-in-the-erlang-erl-td3528347.html#a3531504的部分解释
apply is a built in function (BIF). It is implemented in C, not Erlang.
>
> apply is a built in function (BIF). It is implemented in C, not Erlang.
Does it work in a similar manner to that of Smalltalks, or differently?
In Smalltalks, `Boolean ifTrue: aBlock ifFalse: aBlock` literal forms
are usually compiled to call into native code directly, so the
implementation of this message in Smalltalk code in Smalltalk VMs looks
like this:
ifTrue:trueBlock ifFalse:falseBlock
^self ifTrue:[ trueBlock call ] ifFalse: [ falseBlock call ]
which looks like it would not work, but when the form
`var ifTrue:aBlockLiteral ifFalse:aBlockLiteral` is encountered the
Smalltalk compiler takes over and replaces this with native code. So the
Smalltalk implementation is only ever hit for non-literal sends (either
non-literal blocks, or usage of selectors), and its only role is to
redirect execution to the native version.
Is the purpose (and behavior) of the pure version of erlang:apply
similar?
----------引用Richard
It's a fairly common "bootstrapping" sort of thing.
Presumably
- when the compiler sees apply/2 or apply/3 in an expression
it generates special in-line code
- there needs to be a "real" function definition so that it
can be called indirectly itself, discoverable in the
module exports, traced if calls arrive that way in the
debugger, &c
apply的调用在beam加载的时候vm会调整相关的指令,实际上是在vm的opcode里面执行的。
专注高性能容错分布式服务器的研究和实现
http://blog.yufeng.info
分享到:
相关推荐
4. **更新引用**:如果新模块的接口有变化,需要通知还在使用旧接口的进程,可以发送信号让它们停止并重新启动,或者使用`erlang:apply/3`来强制执行新版本的函数。 三、注意事项 - 热部署可能会影响正在运行的...
2017 | ASIN: B06XHSP5SH | 212 Pages | AZW3 | 1.85 MB If you’re new to Erlang, its functional style can seem difficult, but with help from this hands-on introduction, you’ll scale the learning ...
函数调用在Erlang中通过`apply(Module, Function, Arguments)`实现,这使得调用其他模块中的函数变得简单。对于未知函数,可以使用`Module:Function(Arguments)`的语法。内置函数如`now/0`返回自1970年1月1日以来的...
首先,`timer`模块的主要函数包括`tc/1,2,3`(测试调用)、`send_after/3,4`(发送消息后延迟)、`apply_after/4`(应用函数后延迟)、`cancel_timer/1`(取消定时器)等。这些函数让开发者能够灵活地设置定时事件,...
插件 该库旨在提供一种简单的方法来管理Erlang应用程序的插件,目前抽象非常简单并且层次很高,但是... eplugin : apply ( my_fancy_callback , [ 1 , 2 , 3 ]) =:= eplugin : call ( my_fancy_callback , 1 , 2 , 3 ).
钢筋灰熊插件 用于 erlang 热代码升级的 Rebar 插件。 将远程节点上的 Beam 文件与应用程序的ebin目录同步(重新加载和保存)。 Grizzly 只对 rpc 使用长名称。安装要安装 grizzly,您需要将其添加为 rebar 配置的...
Erlang and OTP in Action teaches you to apply Erlang’s message passing model for concurrent programming–a completely different way of tackling the problem of parallel programming from the more ...
在应用中,可以创建Celery实例,定义任务,并通过`apply_async()`方法将任务放入队列。RabbitMQ作为消息中间件,负责在后台调度和分发这些任务。这样,即使发送任务的客户端和执行任务的工作节点不在同一时间在线,...
grade_trace:apply({file, "trace"}, jiffy, encode, [{[{name, app_name}, {type, application}, {desc, description}]}]). grade_trace:consume({file, "trace"}, Db). TODO 和请求的功能 我们应该基于哪个跟踪器...
升级/降级架构和迁移erlang应用程序数据库数据的工具 安装 运行make deps以安装depident 运行make来编译代码 用法 参数Options数据结构是map 创建迁移src文件 Args = #{ schema_name => mhs, migration_src_...
Book Description, RabbitMQ is Open Source Message Queuing software based on the Advanced Message Queue Protocol Standard written in the Erlang Language. RabbitMQ is an ideal candidate for large-scale...
Because Elixir runs on the Erlang VM, and uses the underlying Erlang/OTP architecture, it benefits from almost 20 years of research into high performance, highly parallel, and seriously robust ...
Description: Functional programming languages like F#, Erlang, and Scala are attracting attention as an efficient way to handle the new requirements for programming multi-processor and high-...
在Elixir中,`&Kernel.apply/2`函数或者使用`&`运算符结合元组可以实现类似的功能。 "Category"在这里可能指的是范畴论,它是数学的一个分支,用于研究结构和结构之间的映射。在编程中,范畴论的概念被用来理解函数...
Mnesia是Erlang语言的标准分布式数据库,RabbitMQ基于它来存储队列、交换机、绑定等信息。 在升级过程中,以下几个关键步骤是必须关注的: 1. **remove_user_scope**:这可能涉及到用户权限管理的更新,移除旧的...