在Erlang中实现接口 [英] Implementing interfaces in Erlang

查看:125
本文介绍了在Erlang中实现接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在erlang中实现接口?模块的结构是什么或者如何设置?

How does one implement an interface in erlang? What is the structure of the modules or how is it setup?

我有一个分层架构,想要实现每个层的接口。允许需要下层的层来处理一些任务来访问或调用这些任务。

I have a layered architecture and want to implement the interfaces in each layer. Allowing the layer which requires the below layer to handle some task to access or call for these tasks.

这个接口模块的功能如何看待?

How would this interface module look in terms of functionality?

推荐答案

界面不存在于动态类型的Erlang世界中。您将不得不在评论中记录行为,或提供透析器的-spec合同来查看。

An interface in the sense of a Java interface or an ML module signature does not exist in the dynamically typed Erlang world. You will have to document the behavior in a comment or provide a -spec contract for the dialyzer to look at.

一般来说,处理语言的最佳方法是不要假设你可以将你现有的知识映射到它中,除非你碰巧知道一个概念中接近的语言。 Erlang附近的语言是Prolog和Scheme。更远的是Python和Ruby,但是他们对OOP设计的依赖使他们进入了视野。任何静态类型,Ocaml,Haskell,Java,C#,C ++等都绝对超出了视野。

In general, the best way to approach a language is by not presuming you can map your existing knowledge too much into it, unless you happen to know a language that is "close" in concepts. Languages close to Erlang are Prolog and Scheme. Farther out comes Python and Ruby, but their reliance on an OOP design puts them into the horizon. Anything statically typed, Ocaml, Haskell, Java, C#, C++ and so on are definitely beyond the horizon.

这篇关于在Erlang中实现接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆