HNHacker News
TopNewBestAskShowJobs

middayc

762 karma · joined April 20, 2009

maker of ryelang.org
submissionscomments
middayc··on When if is just a function
True, there is the "old maintainer" aspect, that differs.

But what exactly does this mean in relation that what are special forms in other languages are function calls in Rye?

Is the problem that you somebody could make their own control-structure-like functions? All these function calls have exactly the same evaluation rules, which is not something you can say about "special forms" in "normal" languages because special forms are exactly rules that break the regular evaluation rules.

Rye already has a lot of control-structure-like functions in it's standard library and many other functions that accept blocks of code and aren't related to control-structures. Yes, a "stupid" person can write "stupid" code in Rye, but you don't need much flexibility in any language to write stupid code.

I fully admit there are languages that are more suited for teams, and languages that are more suited for solo developers, for this reason.

That was also my point mentioning "million pixel website" because that "art" is directionless and crowdsourced and a painter can use the same pixels or even more flexible options to create beautiful images.

middayc··on When if is just a function
I used R for a while to do visualizations, but I never got to it's more homoiconic side, but I saw since then that it has it.

Can you also put code into { 6 }, like { print(6) }?

Does this overwrite R's if or how does the scoping in R work?

middayc··on When if is just a function
You can't delete word binding in Rye. I will have to add some solution just for REPL, because sometimes you instantiate something and make a bug and need to reiterate, but in the language itself no.
middayc··on When if is just a function
Sorry, but I don't understand the example. In Rye, as in REBOL all first level block evaluations (do, if, for, loop, ...) happend in current scope (context).

Rye has first class contexts and it's one of more exciting things to me about it, but I'm not sure it's related to what you describe above. More on it here:

https://ryelang.org/meet_rye/specifics/context/

One thing that pops out at the example above is that I wouldn't want to define a y inside if block, because after the if you have y defined or not defined at all, at least to my understanding of your code.

Rye is constant by default, most things don't change and you need less veriables because it's expression based and it has left to right "flow" option. So you only make variables where you really need them, which is less common and specific, it should be obvious why you need a variable.

middayc··on When if is just a function
What exactly would be the e. coli here?

I mean this is not the first dynamic, homoiconic, reflective language. Which one of these os something I didn't list is the obvious negative or e. coli as you call it?

middayc··on When if is just a function
You still have this problem? I tested and fixed css yesterday. What exactly is problematic?
middayc··on When if is just a function
If Python has special syntax for `if` and so makes if an expression, it doesn't mean that `if` is a function.

If `if` is a function why don't you call it like other functions in Python?

    if( .... )
Functions are first class in Python now AFAIK. Can you assign `if` to a variable?

Also, blog-posts is not just about `if`, is `for` a function in Python, `def`, `return`, `class`?

middayc··on When if is just a function
This is another subject but mathematical operators are and behave (for better and worse - there are also negative consequences of this consistency) like all other op-words, they just don't need . in front and correct, non-op-word is prepended by _.

    12 + 23    ; is technically
    12 ._+ 23  ; or not using op-word is
    _+ 12 23   ; or if we bind function _+ to add
    add: ?_+   ; we get
    12 .add 23 ; and
    add 12 23
It has downside because op-words don't behave exactly as math expressions would, but you can use parenthesis and we have a math dialect which includes full math precedence rules.

    math { 12 * 2 + 23 * 3 }
middayc··on When if is just a function
I've been programming in REBOL for decade(s) so this is just how it worked and made sense and we never used term "lazy evaluation", so it not part of my vocabulary when explaining this.

Blocks are not evaluated by default, but they are eagerly evaluated if the function that accepts it decides to do so (if, do, loop) ... I understand lazy evaluation more like something that is meant to be evaluated, but physically only gets evaluated when or if you do need the result, which I'm not sure is entirely the same.

middayc··on When if is just a function
I agree. This is not something you would usually use to program, at least not all three together, but as it's written it's consistent and signals exactly what it does, to someone that knows Rye conventions / rules.

I can break it down for you, but yes ... it's quite specific, I was trying to apply an `if` which is not something I needed to do or would look to do so far. The point is that you can also apply all "control structure like" functions, like any other function - consistency, not that this is advised or often used.

?word is a get word. `x: inc 10` evaluates inc function, so x is 11, but `x: ?inc` returns the inc function, so x is the builtin function.

apply is a function that applies a function to a block of arguments. It's usefull when you want to be creative, but it's not really used in run of the mill code.

.apply (op-word of apply) takes first argument from the left. `?print .apply [ "Hello" ]`

Here we needed to take second argument from the left and this is what a * modifier at the end of the op- or pipe-word does. `[ "hello" ] .apply* ?print`

You asked for it :P

middayc··on When if is just a function
That is sort of like saying all visual art projects want to become "the million dollar / pixel homepage" so providing an empty canvas and full color palete will just enable people to create visual sewage because nothing stops them from doing so.

I never programmed in a team, so my experience of programming is probably very different from yours. You probably want something like electric cattle fencing (if I borrow your juicy language) for your team, but if I program for my self I just want an open field of Rye I can explore :)

middayc··on When if is just a function
My bad :), Gilligan typed language would resolve this at compile time. Will fix.
middayc··on When if is just a function
Python was used as an example because people know Python and reader can compare it to something known.

I wasn't trying to make Python look awkward. I was trying to write equivalent Python, you are very much welcome to suggest improvements to my Python examples.

Other languages could be used instead of Python, for example Javascript. But I feel Python is more contained language, with clear ways to do thing (I guess I don't know them that well :) )

middayc··on When if is just a function
It depends on what you want. If you want the most stabile and predictable way to specify the behavior, then static control structures have little downsides.

If you want to explore with how you can specify behaviors or rules and create new options or the ones tightly fitting your problem domain or mental model, then this gives you more tools to do so.

middayc··on When if is just a function
interesting. Give us an example of it's usage ... or how you implemented it?
middayc··on When if is just a function
I’ve personally always thought that REBOL’s use of set-words and similar constructs was a strength. It makes sense conceptually, is visually distinguishable, and maintains a strong sense of internal consistency.

REBOL (and by extension, Rye) was never designed around the idea that everything must be a function. It just turns out that this approach fits naturally within the core principles and rules of the language.

All “active” words happen to be functions, because nothing else is needed. The behavior of different word types (and, more broadly, value types) is determined by the evaluator. In that sense, you could say that Rye does have syntax, expressed through its distinct word types.

middayc··on When if is just a function
You can do it, but that is not how the (default) control structures work in those languages. There is usually also some syntax cost.
middayc··on When if is just a function
You can't really redefine if because everything is a constant, but you can define if in your own context yes.
middayc··on When if is just a function
Yes, Io language is closest to that syntax probably:

https://iolanguage.org/guide/guide.html#Introduction

middayc··on When if is just a function
Yes, Rye follows REBOL in this case. Plain block invocation doesn't create it's own scope / context. That holds for do, if, either, loop, for, map, etc.

It would be costly to have this on by default. If you want separation there are many ways to achieve it. Rye has many functions related to contexts / scopes. For creating contexts in multiple ways and evaluating code inside contexts or with context as parent or isolated context, etc.

And a lot of builtins directly accept anonymous functions in place of blocks of code.

For example for loop also accepts function if you want separation and don't mind the cost.

    for { 1 2 3 } fn { x } { print x }
    ; which can also be written with fn1
    for { 1 2 3 } fn1 { .print }
    ; or latest experiment where we have syntax for 3 injected blocks 
    ; .() - same as "with"
    ; .[] - same as "reduce/with"
    ; .{} - same as "fn1"
    ; where it's already decided department from REBOL: 
    ; () is "do"
    ; [] is "vals"
    ; {} is literal block 
    for { 1 2 3 } .{ .print }
middayc··on When if is just a function
I don't know a lot about Tcl, but one thing I know is said for it "everything is a string". In REBOL's it's somewaht reverse as all this live code are REBOL (Rye) values and REBOL (and Rye) have an unusual number of datatypes, REBOL 30+ (many literal types), which it uses as additional information for functions to work with, and is usefull at creating dialects

For example file-path, url and email address are distinct types in REBOL where in mosta languages are just strings.

middayc··on When if is just a function
Rye is foremost a REBOL and REBOL has this notion of many types of words at it's core:

`word` - regular word, can evaluate to value it's bound to or call a funtion if bound to a function

`word: "value"` - set-word, assignment that you noticed

`probe :word` - get-word, always returns bound value, doesn't call a function if it's bound to a function, in Rye this is `?word`, because `:word` is left-set-word.

`'word` - literal word, evaluates to a word itself

etc ...

Rye adds even more word types. Rye also has left to right flow so it adds left-set-word. In Rye all assigned words with set-words are constants and they are used by default. So we also need a "mod-word", that is the double colon that you noticed, and left-mod-word. Because of left-to-right flow Rye also has .op-words and |pipe-words.

The logic around words, op-words and pipe-words ... I tried to explain here:

https://ryelang.org/meet_rye/specifics/opwords/

Another pattern you noticed (good observation btw:) is the idea of injected blocks that isn't used just for loops, but also for conditionals, function bodies, HOF-like functions etc ...

https://ryelang.org/meet_rye/specifics/injected_blocks/

All in all it is supposed to be a compact set of ideas that fit together. Some are somewhat unusual.

middayc··on When if is just a function
I fixed it thanks! I was able to activate dark more in Firefox on desktop and find problems with CSS.
middayc··on When if is just a function
there is no if { } else { } in REBOL or Rye and it wouldn't really fit. There is either function that accepts two code blocks. It can act as a typical if / else or as a ternary expression as it also returns the result of a block:

    print either pwd = "correct" { "Hello" } { "Locked" }
This is Rebol's doc on either, Rye's works exactly the same: https://www.rebol.com/docs/words/weither.html
middayc··on When if is just a function
There is a language https://sprylang.se/index.html which started more as Rebol and moved towards Smalltalk.
middayc··on When if is just a function
Thank you all for heads up! I was playing with CSS and didn't test the dark mode. I think it's fixed now.
middayc··on When if is just a function
I checked in Firefox and Chrome (on Linux) and code samples look OK to me. What browser/OS are you using. Maybe send me a screenshot at janko dot itm at gmail.
middayc··on When if is just a function
Any concrete feedback on looping mechanisms being confusing is appreciated.
middayc··on When if is just a function
BTW: In Lisps, if is still a special form / macro, because in Lisp lists are evaluated by default, in Rebols if can be a function because blocks (lists) aren't evaluated by default.
middayc··on Ask HN: What are you working on? (September 2025)
When I am not working on my 'job' project, I am working on Ryelang.

In September, I was working on language core, console, generic methods, etc ... but this week I updated integration with OpenAI, IMAP, Surf (browser like client) and then I did few experiments by meshing together these libs.

These few lines proved to be quite helpful for my work email :)

    read-file: fn { f } { .Read .trim }
    line: "\n----\n"
    
    cli: imap-client read-file %.imap-user read-file %.imap-pwd "secure.emailsrvr.com" 993
    |Select-folder "INBOX"
    |Search-emails "UNSEEN SINCE 30-Sep-2025" :uids
    
    cli .Get-emails uids 
    |map { -> "text" } |join
    |concat3 line " Summarize the most important emails above and report them to me. Then separately report the most URGENT ones." :cmd

    oai: openai read-file %.oai-token
    oai .Chat\stream cmd { .prn }

I also tried to write/use these libs interactively: https://asciinema.org/a/745616

and made a "console applet": https://pbs.twimg.com/media/G2FXUepWgAAn7cu?format=jpg&name=...

... since you asked :)

← PreviousPage 2 of 10Next →