Which are the cases that make it hard to distinguish between code and data?

218 Views Asked by At

It is said code is data (and vice versa, i.e. homoiconic) in Rebol and Red. Also, it is said that it's impossible to distinguish between the two. My understanding is that there are 2 cases here:

  1. Determine with certainty code from a mix of code and data
  2. Determine with certainty data from a mix of code and data

mix of code and data is my name for what outsiders would usually call Rebol code, and experienced Rebol programmers say is data (there is no code, only data)

Motivation

The code vs data distinction make some features in programming languages easier. For e.g. disassembly was mentioned (sbcl has the disassemble function).

Question

What are examples of these problematic cases?

context:

from chat on March 15, 2017 3:32 PM: (emphasis mine)

Didec: You forget that there is no code in Redbol, only data.

Maximvl: well, it's same for CL and SBCL complies everything down to native code and since code = data, one can say that there is no data, only code

It is not the same in Lisp languages, there is a distinction between "code" and "data" [in Lisp], as code has to start with a call. Redbol has no such restriction on code, which makes it very different.

also:

Moreover, contexts and dynamic binding make it way more flexible, but at the same time, translating directly to low-level assembly code, like in your CL example, is not possible.

Aside: Does this mean Rebol is more homoiconic than Lisp?

1

There are 1 best solutions below

0
On

Here's one:

[q]

Outsiders will recognize the Q function and see this as a code block, while Rebol insiders will know that it must be data because Q is only called from the top level of the interpreter.