meijeru / red.specs-public

Formalized description of Red: lexical, syntactic and semantic
15 stars 7 forks source link

On the evaluation formalism in Red (Rebol, Spry, ...) #4

Open dumblob opened 4 years ago

dumblob commented 4 years ago

@meijeru I think to increase credibility of a language and the overall understanding, more formalism would undoubtedly be beneficial.

Recently I came across Call By Push Value which seems to be the underlying central building block of Rebol/Red/Spry/Levy/... languages.

Could you take a look and add it to the docs?

meijeru commented 4 years ago

I have some difficulty with your statement " Call By Push Value [...] seems to be the underlying central building block of Rebol/Red/Spry/Levy/... languages". Can you explain why you think CBPV is applicable to (the evaluation mechanism of) Red?

9214 commented 4 years ago

Thanks for the link @dumblob, that's an interesting paradigm. But I'm afraid it's not related to Red and Rebol, can't say about other languages.

As I understood from a brief reading, CBPV provides a unifying formalism for λ-calculus into which both call-by-value and call-by-name reduction strategies can be converted, which is useful for PLDI research — instead of 2 different semantics you use just 1.

Red's interpreter uses call-by-value by copying arguments (value slots) onto evaluation stack, but some values contain references to external data outside them, thus giving the ability to mutate said data in-place (unless you explicitly copy it), which looks like a call-by-reference to the uninitiated.

Other dialects (eDSLs and general-purpose languages) can use entirely different calling conventions and implement their own runtimes around what you call "underlying central building block" — the common data format (which Red is, by the virtue of homoiconicity).

So, yes, in that sense Red can subsume call-by-value and call-by-name just like call-by-push-value, but IMO that's too far-fetched. "Functional/imperative synthesis" also somewhat resonates with Red, but that's debatable too.

In our previous encounter, I gave you some pointers on how evaluation in Red and Rebol works. Please review them once more and ask questions in our community chat if something needs further clarification.

It's really a block!, no pun intended.