Earlier quoted context omitted.
Presumably as functions, the same way as excel? and(x, y) -> bool or(x, y) -> bool if(cond, funcTrue, funcFalse) -> void
Yeah I did notice in the examples fac: fn { x } { either x = 1 { 1 } { x * fac x - 1 } } ; function that calculates factorial So presumably "either" is the "if" expression.
Rye: Homoiconic dynamic programming language with some new ideas
11–20 of 86 posts
Re: Rye: Homoiconic dynamic programming language with some new ideas
#12Re: Rye: Homoiconic dynamic programming language with some new ideas
#13Earlier quoted context omitted.
This is possible with fexprs or equivalent constructs https://en.wikipedia.org/wiki/Fexpr It looks like that's how Rye does it as well, blocks can be conditionally evaluated: https://ryelang.org/meet_rye/basics/if_either/ "In REBOL, contrary to Lisps, blocks or lists don’t evaluate by default. For better or for worse, this little difference is what makes REBOL - REBOL." https://ryelang.org/meet_rye/basics/doing_block…
I mean, it's possible in lambda calculus. Anything above that is sugar, right?
Turns out the language does have special forms, which is OK; it's just weird to say there aren't (though it's an understandable goal).
When I worked on 3Lisp (so many decades ago) it became clear to me how many special forms there are (a small number, but more than I thought) and, honestly, how few there really are, so the "benefit" of a 3Lisp turns out to be negligible in practice. Oddly enough I didn't really notice that when writing interpreters because I thought of most special forms as simply compiler hacks ("eventually we can get rid of this").
Re: Rye: Homoiconic dynamic programming language with some new ideas
#14> Rye is homoiconic, it has no keywords or special forms (everything is a function call, everything is a value) How does it implement and , or , or if ?
This is possible with fexprs or equivalent constructs https://en.wikipedia.org/wiki/Fexpr It looks like that's how Rye does it as well, blocks can be conditionally evaluated: https://ryelang.org/meet_rye/basics/if_either/ "In REBOL, contrary to Lisps, blocks or lists don’t evaluate by default. For better or for worse, this little difference is what makes REBOL - REBOL." https://ryelang.org/meet_rye/basics/doing_block…
It is interesting to imagine inverting the sense of execution, but as you say it's hard to do much optimization.
Re: Rye: Homoiconic dynamic programming language with some new ideas
#15The blog entry titled "Less variables, more flows example vs Python" is strange. ( https://ryelang.blogspot.com/2021/11/less-variables-more-flo... ) The Python version uses intermediate variables so the author of the code is to blame for verbosity, not the language.
I think I wrote a script I needed in Rye and I found it interesting, then I went to Fiver and paid someone to write a script in Python that does the same.
2021 were different times, and I hope I've grown a little too... and now I would ask ChatGPT or Gemini :)
Re: Rye: Homoiconic dynamic programming language with some new ideas
#16Re: Rye: Homoiconic dynamic programming language with some new ideas
#17> Rye is homoiconic, it has no keywords or special forms (everything is a function call, everything is a value) How does it implement and , or , or if ?
https://ryelang.org/meet_rye/basics/if_either/
The tricky thing about if, and, and or --- the reason you can't implement them as functions in most languages --- is that they need to not evaluate all their arguments immediately. Otherwise:
// Would print!
if(false, print("oops!"))
// Would throw an error if the key is not present
and(my_hashmap.has_key("key"), my_hashmap["key"])
The way that ryelang gets around this is that you pass the arguments in a "code block" surrounded by "{}", which delays its evaluation. So you write: // Does not print, because *if* never runs its code block arg
if 0 { print("oops!") }
// There's no example of *and* anywhere but my guess is you'd write this:
and { my_hashmap.has_key("key") } { my_hashmap["key"] }Re: Rye: Homoiconic dynamic programming language with some new ideas
#18> Rye is homoiconic, it has no keywords or special forms (everything is a function call, everything is a value) How does it implement and , or , or if ?
loop is a function that also accepts two, integer for number of loops and again a block of code.
Even fn that creates functions is a function that accepts two blocks, first is a list of arguments and second is a block of code. There is no big difference between function fn and function print, they are both builtin functions defined in same manner and there are multiple fns for special cases and you can create your own on "library" level.
Re: Rye: Homoiconic dynamic programming language with some new ideas
#19familiar with rebol, but evaluation rules with op and pipe words gave me headache. would like to know more about context oriented programming, tutorial had nothing in the section, unfortunately
I am still learning to explain or even name things, but various examples of using contexts in different ways are currently what excites me the most. I will write "Meet Rye" further and contexts are one of next subjects to be written about.
Re: Rye: Homoiconic dynamic programming language with some new ideas
#20The detail about input validation is a really nice one that hopefully the next generation of programming languages all do standard.