编程语言需要哪些功能?

发布于 2024-10-24 02:02:20 字数 217 浏览 5 评论 0原文

最近我的大学为本科生设立了大型项目。其中一个项目是创建一种新的编程语言,其中包含其他语言的所有最理想的部分。现在,我知道很多事情对我来说很难有效地(甚至紧密地)实现 - 例如,使语言非常接近自然语言。

有一些很好的功能,例如高阶函数和用于交换两个变量值的运算符。然而,我正在努力想出很多建议,因此我们将非常感谢一些建议 - 最好的建议将被标记为答案。不过,我只是在这里寻找想法,而不是如何实现它们的方法。

Recently my university has set large projects for its undergraduates. One of these projects is to create a new programming language with all of the most desirable parts of other languages. Now, I know that many things would be pretty infeasible for me to implement efficiently (or even closely) - making the language very close to natural language for example.

There are some neat features that would be nice, like high order functions and an operator for swapping the value of two variables. However I am struggling to think of very many, so some suggestions would be very much appreciated - the best one gets marked as the answer. I am only looking for ideas here though, not methods for how to implement them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

简单 2024-10-31 02:02:20

我喜欢的功能:

  • 关联数组,这样我就可以执行 price["apple"] := 0.99
  • for-each 循环之类的操作,这样我就不必担心索引集合中不存在的
  • 元素用于赋值的 := 运算符,而不是 = ;)
  • switch-case 语句允许除数值以外的值,例如: case "apple": Price : = 0.99 。
  • 作为有效数据类型的数字/日期范围。
  • 具有命名参数和默认值的函数
  • 对正则表达式操作的本机支持(如 Perl)

Features I like:

  • associative arrays so I can do things like price["apple"] := 0.99
  • for-each loops so I don't have to worry about indexing non-existant elements of a collection
  • the := operator for assignment, instead of = ;)
  • switch-case statements that allow for things other than numeric values, eg: case "apple": price := 0.99.
  • ranges of numbers/dates as a valid datatype.
  • functions having named parameters and default values
  • native support for regex operations (like Perl)
笑饮青盏花 2024-10-31 02:02:20

多重继承会很好......尽管它在任何当前语言中都不可用。

Multiple Inheritance would be nice...though it's not available in any current languages.

亚希 2024-10-31 02:02:20

目前,我渴望像 JavaScript eval 这样的语言功能,并具有执行已评估指令序列的额外功能:

execute_THIS( a += b; c = myfunc(a); if c < 0 exit(); );

也就是说,语言运行时可以解释并执行用该语言编写的语句。

——p

At present, I'm yearning for a language feature like JavaScript eval, with the additional power that it would execute the eval'ed instruction sequence:

execute_THIS( a += b; c = myfunc(a); if c < 0 exit(); );

That is, the language run-time could interpret and execute statements written in the language.

-- p

找回味觉 2024-10-31 02:02:20

最强大的一个:

  • 动态类型
  • 语言,不隐藏任何
  • 功能作为一等公民。 (允许使用函数式编程)
  • 运行时自省
  • 语言允许过度驱动默认函数和对象。
  • 元编程
  • 动态代码生成
  • 该语言的扩展语言(只有lisp有这个)

The most powerful one:

  • Dynamic Types
  • Language that don't hide anything
  • Functions as first class citizens. (which allow to use functional programming)
  • Runtime introspection
  • Language allow to overdrive default functions and object.
  • Meta programming
  • Dynamic Code generation
  • Extending Language in this language (only lisp have this)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文