我在哪里可以获得有关Homoiconicity的更多信息?

时间:2022-07-06 02:34:40

I have been experimenting with functional programming and I still dont understand the concept. Do you guys know any good books or tutorials or examples that discuss this concept? Or if you could show small snippets about its usage, that would be great.

我一直在尝试函数式编程,我仍然不理解这个概念。你们知道讨论这个概念的任何好书或教程或例子吗?或者,如果您可以显示有关其用法的小片段,那就太棒了。

4 个解决方案

#1


I believe that Why Functional Programming Matters by John Hughes is one of the best.

我相信John Hughes为什么功能编程很重要是最好的之一。

#2


Learn lisp or scheme. The language is the datastructure is the language. Lisp code and Lisp data structures have the same syntax rules.

学习口齿不清或计划。语言是数据结构是语言。 Lisp代码和Lisp数据结构具有相同的语法规则。

If you learn tcl, you can work with a language that's procedural and the data structure syntax rules are the same as the programming language syntax rules.

如果您学习tcl,则可以使用程序语言,并且数据结构语法规则与编程语言语法规则相同。

It's not -- strictly speaking -- a functional programming issue. It's more an issue with a few languages where the syntax rules for data and the syntax rules for the language are the same.

严格来说,这不是一个功能性编程问题。对于数据的语法规则和语言的语法规则是相同的,使用几种语言的问题更多。

#3


Wikipedia: http://en.wikipedia.org/wiki/Homoiconic

C2 Wiki: http://c2.com/cgi/wiki?HomoiconicLanguages

C2 Wiki:http://c2.com/cgi/wiki?HomoiconicLanguages

#4


REBOL is a homoiconic language. The block! datatype in REBOL is a set of square brackets within which are any valid REBOL tokens, similar to an S-expression in Lisp. For instance:

REBOL是一种同性语言。块! REBOL中的数据类型是一组方括号,其中包含任何有效的REBOL标记,类似于Lisp中的S表达式。例如:

series: [1 2 3 4]
foreach item series [
    print item
]

Now, let's express that a little differently:

现在,让我们表达一点不同:

series: [1 2 3 4]
for-body: [print item] ; This is the body of our foreach
foreach item series for-body

Though it was declared as data, we treated the block for-body as code when we passed it to the foreach function. If we ask REBOL what the type of the first item in the block for-body is — type? first for-body — it will tell us word! and not function! (or native! or action! or any of the other REBOL function types). The reason is that as data, for-body is just an unevaluated chunk of REBOL words. When we pass it to foreach only then does it get evaluated as code.

虽然它被声明为数据,但是当我们将它传递给foreach函数时,我们将块for-body视为代码。如果我们问REBOL块体内第一个项目的类型是什么 - 键入?首先是身体 - 它会告诉我们的消息!而不是功能! (或原生!或动作!或任何其他REBOL功能类型)。原因在于,作为数据,for-body只是一个未评估的REBOL单词。当我们将它传递给foreach时,它会被评估为代码。

Some have called REBOL "like Lisp but without the parentheses" and I personally prefer it to Lisp, but you may not. Still, it's a great language to start with when you want to learn about homoiconicity, a subject I find fascinating.

有些人称REBOL“像Lisp但没有括号”,我个人更喜欢Lisp,但你可能不会。尽管如此,当你想要了解同性恋时,这是一个很好的语言,这是一个我觉得很有吸引力的主题。

#1


I believe that Why Functional Programming Matters by John Hughes is one of the best.

我相信John Hughes为什么功能编程很重要是最好的之一。

#2


Learn lisp or scheme. The language is the datastructure is the language. Lisp code and Lisp data structures have the same syntax rules.

学习口齿不清或计划。语言是数据结构是语言。 Lisp代码和Lisp数据结构具有相同的语法规则。

If you learn tcl, you can work with a language that's procedural and the data structure syntax rules are the same as the programming language syntax rules.

如果您学习tcl,则可以使用程序语言,并且数据结构语法规则与编程语言语法规则相同。

It's not -- strictly speaking -- a functional programming issue. It's more an issue with a few languages where the syntax rules for data and the syntax rules for the language are the same.

严格来说,这不是一个功能性编程问题。对于数据的语法规则和语言的语法规则是相同的,使用几种语言的问题更多。

#3


Wikipedia: http://en.wikipedia.org/wiki/Homoiconic

C2 Wiki: http://c2.com/cgi/wiki?HomoiconicLanguages

C2 Wiki:http://c2.com/cgi/wiki?HomoiconicLanguages

#4


REBOL is a homoiconic language. The block! datatype in REBOL is a set of square brackets within which are any valid REBOL tokens, similar to an S-expression in Lisp. For instance:

REBOL是一种同性语言。块! REBOL中的数据类型是一组方括号,其中包含任何有效的REBOL标记,类似于Lisp中的S表达式。例如:

series: [1 2 3 4]
foreach item series [
    print item
]

Now, let's express that a little differently:

现在,让我们表达一点不同:

series: [1 2 3 4]
for-body: [print item] ; This is the body of our foreach
foreach item series for-body

Though it was declared as data, we treated the block for-body as code when we passed it to the foreach function. If we ask REBOL what the type of the first item in the block for-body is — type? first for-body — it will tell us word! and not function! (or native! or action! or any of the other REBOL function types). The reason is that as data, for-body is just an unevaluated chunk of REBOL words. When we pass it to foreach only then does it get evaluated as code.

虽然它被声明为数据,但是当我们将它传递给foreach函数时,我们将块for-body视为代码。如果我们问REBOL块体内第一个项目的类型是什么 - 键入?首先是身体 - 它会告诉我们的消息!而不是功能! (或原生!或动作!或任何其他REBOL功能类型)。原因在于,作为数据,for-body只是一个未评估的REBOL单词。当我们将它传递给foreach时,它会被评估为代码。

Some have called REBOL "like Lisp but without the parentheses" and I personally prefer it to Lisp, but you may not. Still, it's a great language to start with when you want to learn about homoiconicity, a subject I find fascinating.

有些人称REBOL“像Lisp但没有括号”,我个人更喜欢Lisp,但你可能不会。尽管如此,当你想要了解同性恋时,这是一个很好的语言,这是一个我觉得很有吸引力的主题。