I like to minimize investing in brackets, so I came up with the following template to make writing functions a joy. App Builder could include additional code management tools and become the basis for a Rebol IDE capable of generating code in all Rebol versions. For instance App builder could include a listbox with many functions ready to use, with the ability to include custom made managed ac…
7 hours later…
7:00 AM
I have, on and off, wondered whether IF should do a trick like the loops are doing now, where if a branch is taken then the result is forced to a BLANK!. So even if print "Hi" has a void result, an x: if true [print "Hi"] sets x to BLANK!. This way, you would be able to use void to determine that the branch was not taken.
If this pattern were applied uniformly, then ELSE could just be an infix operation that evaluates its left and if it's void, runs the code on its right. You could say switch thing [blah [...] blah [...]] else [...]...basically any construct that could come back as a void could have an else clause.
This appeals to me because the "brancher" logic is not only more complex, it's more costly...you have to generate a function, and then call the function. This is inexpensive, easier to understand, and means you don't have to put in a "/?" switch on all the control constructs... you can write them all as e.g. if?: chain [:if | :any-value?]
The downside is that you can't easily bubble a void out of a conditional expression, and the most common example of that would be something like x: if condition [:y], where you are trying to mirror the value of a variable into another one based on a condition, and you think of "unsetness" as being in that range. There's likely not much legacy code that looks like that, because x: () was illegal until Ren-C.
1 hour later…
8:47 AM
Some progress. My app is now detected by Amazon Echo as a Philips hue bridge, and I can control my lights on/off using voice and rebol :)
9:02 AM
This would hurt stuff like compose [blah (case [a [do stuff ()] b [do stuff fill in stuff]]) blah blah]... e.g. if you wanted to do some processing yet still wanted to have some of your cases signal an opt-out. But as long as you're willing to use blank for that, you could say opt case [...]; it just means you couldn't literally place a blank in. I think this is a fine tradeoff.
9:30 AM
@GrahamChiu CASE didn't have an ELSE, that's sort of the trick of the ELSE as infix operator. Although you might argue case "did have an else" since it spoke a protocol of "branchers".
Now that's going away, but I'm going to miss being able to put code in mid-CASE to say "if you got this far in the cases, run some code, then keep matching"
But overall, I think the balance needs to keep pushing toward that goal of simple with large force multiplier. There's a big difference between invasively asking every construct that does something "branch-like" (whatever that means) to consider either a block or a function as a candidate and maybe pass that function a LOGIC! if it's arity 1... vs. just saying "make your construct return void if you didn't do anything"
10:16 AM
Though if you write foo: func [condition x] [either condition [bar x] [baz x]] you wind up losing information if bar or baz return voids. :-( This is a little trickier; it's information loss when you are dealing with functions that are black boxes. I think this black-box scenario is what discouraged me from trying to tamper with branches in the past.
2 hours later…
12:28 PM
One answer, which I think might be a good answer, would be if procedures don't return void, but they return BLANK!. This would mean that voids falling out of branches would be uncommon enough that you wouldn't really care if you said foo: if x [:some-var] else [:other-var] and some-var was void, so it wound up taking what other-var returned. That might even be what you want.
This means EITHER and IF-ELSE would not be technically equivalent, which isn't necessarily the end of the world as long as people understand there's no such thing as "IF-ELSE"... just IF and ELSE. You can even write either condition [x] [y] else [z], and if whichever branch is taken winds up being void you still run the else. You could also chain as many elses as you want.
1:16 PM
Well, it's a bigger deal than that, because you could say if condition1 [if condition2 [...]] else [...], and then a false condition2 would mean you'd get a void branch and run the else clause. I don't think this is the end of the world, though. It seems to me actually that reimagining ELSE to be more generically meaningful is a better idea than breaking the pass-thru logic of all the conditionals.
2:00 PM
« first day (2297 days earlier) ← previous day
