elixir 模块名一些参考资料

elixir 的模块名实际上是一个atom 类型的数据,以下是一些参考资料

参考使用

比如一个mix sup 项目

defmodule EctoDemo.Application do
  use Application
 
  @impl true
  def start(_type, _args) do
    children = [
 
    ]
    # 此处name 实际上就是使用了模块名格式的,因为是一个atom,所以此处可以使用任意名称,只是默认项目使用了EctoDemo.Supervisor 格式的,明确这是一个Supervisor 
    opts = [strategy: :one_for_one, name: EctoDemo.Supervisor]
    Supervisor.start_link(children, opts)
  end
end


实际上可以修改为其他格式的,通过observer 监控看到的信息如下(我修改了name 为EctoDemo.Supervisor.Dalong)

参考资料

https://tylerpachal.medium.com/why-do-erlang-modules-look-like-atoms-in-elixir-9fb2f964dd2b
https://www.oreilly.com/library/view/programming-elixir/9781680500530/f_0060.html
https://stackoverflow.com/questions/29674102/is-elixirs-module-an-atom
https://hexdocs.pm/elixir/1.15.7/Module.html
https://hexdocs.pm/elixir/1.15.7/Supervisor.html
https://elixirforum.com/t/what-are-module-and-function-names-exactly-they-seem-to-be-more-than-atoms/47632/4

posted on   荣锋亮  阅读(5)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2023-01-04 dremio DatasetSaver 服务说明
2023-01-04 dremio datastore简单说明
2023-01-04 piperider 开源数据可靠性工具
2022-01-04 census 安全处理模式
2022-01-04 castled 简单原理说明
2021-01-04 goja 支持es6的一种方法
2021-01-04 salesforce 跨组织数据可见性的方案

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示