4 ms·
For language enthusiasts, here are some interesting features of Red (and Rebol): - You can pass unevaluated expressions to functions, which can then choose to
by shalabhc 9y ago
For language enthusiasts, here are some interesting features of Red (and Rebol):
- You can pass unevaluated expressions to functions, which can then choose to evaluate the expressions any way they want. This sounds similar to 'fexprs' in some lisps.
- Scoping is very 'flexible' - you can take a function body and evaluate it in another 'context' which provides different values for all the words in the body.
- Making mini dialects (DSLs) is supposed to be easy and seems very common. It uses the `parse` function, which is a dialect used to define dialects. The parsing model is PEG like. The `view/options` for instance is a dialect being used for defining the GUI in the linked post.
- Red/System is a dialect for system programming (C-level semantics, and performance)
Overall it's a very interesting language and very impressive that it's also compact - the binaries are ~1MB on each platform.
- 9214 9y agoTo clarify: - unevaluated expressions are called blocks, and with them the line between code and data blurs, since you can treat block as either one at any time (homoiconity); - there're no scopes, only namespaces (contexts); - yes, Parse is one of the Red's crown jewels, many people (and author of the article himself) treat it as some kind of "plain English regex", while in fact it's not limited only to string parsing, but can be applied to any other series-like value and code (i.e. blocks) itself, which allows for some cool metaprogramming tricks; - R/S (without any optimization layers whatsoever) is 2-3 times slower than C.
- shalabhc 9y agoThanks for the clarifications. > it's not limited only to string parsing, but can be applied to any other series-like value and code (i.e. blocks) itself Sounds somewhat similar to OMeta (http://www.tinlizzie.org/ometa/ http://www.tinlizzie.org/ometa/) which can pattern match streams of objects. With contexts it sounds like almost every word can be late bound? Also it seems blocks and contexts are decoupled which means you could evaluate multiple blocks from different parts of your program in the same context, or give each a unique context, etc?
- 9214 9y agoEvery word (the thing what author calls a "variable") has a binding. In short, it's a pointer to the namespace where value associated with that word resides. Blocks can nest any other value, including words. At any point in runtime you can change this pointers (bound word to some value) for every word in a block or for separate words.
- greggirwin 9y agoYou can pattern match streams of values, and those values can be any lexical form that Red supports.
- throwaway7645 9y agoI'm not sure how easy it is to do DSLs. You don't see this popup in the Red or Rebol docs for a reason. It is homoiconic like Lisp, so it should be feasible. I'd love to hear some of the core devs like doc respond.
- 9214 9y agoIt might get hairy if DSL is non-trivial, IIRC Doc has plans to implement meta-DSL wrapper (a la Rascal) sometime after 1.0 launch to ease the process.
- throwaway7645 9y agoI hope Red puts up a couple of really simple examples on how to build DSLs. It's one of the great things Red/Rebol has to offer, but it isn't obvious how to do it.
- 9214 9y agoI guess you can start with [1] and ask people in community, there may be a couple of simple examples to show. [1]: https://github.com/red/red/wiki/Red---Rebol-Dialects:--Selected-Articles-and-Links https://github.com/red/red/wiki/Red---Rebol-Dialects:--Selec...
- throwaway7645 9y agoI've tried asking the community before and the response wasn't good. With that being said, the links you sent were pretty nice, so thank you!
- 9214 9y agoYou're welcome! I actually rather interested in DSL creation myself and want to dabble my feet in this topic sometime. And I also feel that creation of dialects is rather obscure art for old-timers, and that there's a need for learning material. With that said, I would appreciate if you'd listed what would you like to see in "How to bake DSL with Parse" guide of some sort, that would be really helpful when the time will come for writing tutorials and documentation.