3 ms·
Also, I found it interesting that this free form of syntax actually can be made quite readable (in comparison to Lisp, which I love in theory but balk at trying
by gokr 11y ago
Also, I found it interesting that this free form of syntax actually can be made quite readable (in comparison to Lisp, which I love in theory but balk at trying to read).
I even think Ni is turning out more readable than Rebol/Red - probably due to the use of keyword syntax and infix arguments. And the idea with arg words made lambdas very lightweight, much more so than in Rebol.
- draegtun 11y agoIt's trivial to add an arg words style lambda to Rebol. For example, here is a very naive version: lambda: function [block] [ args: sort unique collect [ parse block [ any [ w: set arg get-word! ( keep to-word arg change w to-word arg ) | skip ] ] ] function args block ] test in REPL... >> f: lambda [:a + :b] >> f 1 2 == 3 >> foo: lambda [c: :a + :b print [:a "+" :b "=" c]] >> foo 1 2 1 + 2 = 3 NB. However you wouldn't really use :arg-name here because this is already reserved for the get-word! datatype.
- gokr 11y agoYes, and I never implied its not hard to do. And examples such as this one are quite impressive - which is what got me interested in Rebol in the first place and triggered the development of Ni. However... if I understand your code properly - you are basically generating an argument declaration by scanning for "get words". So its still a static declaration. In Ni an arg word is an operation. That means a Ni func can decide how many arguments to pull, and in which order, dynamically, much like stack oriented languages can do. Usefulness? Dunno :) But its not the same. Also, yes, I opted out of set words in Ni since I want to be able to have keyword syntax á la Smalltalk/Self. And I use "^" instead of ":" prefix for get words, because I wanted the argwords to be similar to how they look in Smalltalk. :)