Should More Operations REDUCE (or COMPOSE) by Default?

For reasons that seem pretty good in practice, PRINT reduces a block given to it.

x: 10
print ["x is" x]  ; gives you `x is 10`, not `x is x`

An alternative would be that you needed to say print reduce ["x is" x]. But that seems laborious. Ren-C has GET-BLOCK!, and though that hasn't been entirely resolved for what it means, it opens the door to print :["x is" x]. That's briefer, but even that seems kind of lame compared to the historical non-colon-needing behavior with reducing.

What exactly was it about PRINT that makes it sensible to REDUCE? Can it be articulated what properties it has that distinguish it from something like APPEND, that would provide guidance to those making their own routines?

New Options with QUOTED! and META-XXX!

We now have META-WORD!, META-BLOCK!, etc. They produce QUOTED! values.

>> x: 1020

>> print ["x is" x]
x is 1020

>> print ^["x is" x]
x is x

>> block: ["x is" x]

>> print block
x is 1020

>> print ^block
[x is x]

Just something to consider. I don't really have answers here, I was just throwing out the question.

Because it makes more sense to do so, and besides that, what else do you expect, for the suggested result "x is x", well let's say, does not compute :wink:

In the end this behaviour is just why everybody was using REJOIN instead of JOIN.

So where it made sense to Carl to have a JOIN and a REJOIN, from the perspective of having similar behaviour in functional behaviour in respect to naming of functions, making that consistent, practise has proven a different need.
We all could have been using the REPRINT function for years, neglecting the obvious PRINT because that did not reduce.
Naming functions is difficult. Best guidance I can think of now is to always be prepared to rename for a better alternative name has been thought of or the given name implies a (slightly) different generally expected behaviour.

1 Like

I did something along these lines, but where actually a PRINT of a quoted thing will MOLD it:

>> print ^["x is" x]
["x is" x]

I think this turns out to be more useful. This gives back some of the ability that people might have liked from simple print ^some-integer if they don't want to type print [some-integer].

(Of course what they probably want is -- some-integer to dump it.)

As a reminder on why PRINT limits its inputs, it's simply a bit dangerous to get people in the habit of saying print value and then having it all seem to work fine and well until one day you have value: [format hard drive]. Using PRINT as a generic value dumper when it has active behavior on blocks has a gotcha...I've limited branch types for similar reasons.

Quite right.

Right now I'm looking at examples of CALL with a BLOCK!. And you nearly always want to REDUCE or COMPOSE it.

Very occasionally you do not want to process it... but usually only because it was already reduced.

So rather than going down the avenue of RECALL :roll_eyes: I propose that CALL at least COMPOSE its argument. If you don't want it to do this, you use a quoted block.

Since there are now more legal options for words, the advantage of doing COMPOSE instead of reduce is being able to say something like:

call [(system.options.boot) --do "print {hi}"]

If it ran REDUCE then you'd have to say things like:

call [system.options.boot "--do" "print {hi}"]

That lines up a little less with how a real command line looks.