JUST vs LIT/LITERAL/LITERALLY

Among purposes we might apply JUST for, I think it could be a better name for LIT.

Quick reminder that QUOTE means something different... it means add a generalized quoting level to the argument:

>> quote 10
== '10

>> x: 10

>> quote x
== '10

>> quote x + 20
== '30

>> quote quote x
== ''10

>> quote/depth [a block] 3
== '''[a block]

I can't think of a better name for that than QUOTE. So what Rebol2's QUOTE did ("give me the following value literally") was taken over by LITERAL.

>> literal x
== x

But when you give an operation a noun name, then it competes with when you might want a variable to hold that. So if you have a list of "literals" you might say for-each literal literals [...]. I had an idea to work around this by calling it LITERALLY:

>> literally x
== x

But both LITERAL and LITERALLY feel too long, so it was abbreviated as LIT:

>> lit x
== x

Which you can get used to, but still it's an abbreviation and not a word, so it is a bit of a wart.

Compared to all of this, JUST ticks all the boxes.

  • short
  • a real, un-abbreviated word
  • not a noun and unlikely to be desired as a variable name

It feels very intuitive:

>> just x
== x

>> quote just x
== 'x

I had thought the name wouldn't matter that much since generic quoting would mean you'd nearly never use it. However, quoting has other effects which means we probably want to encourage people not to use evaluative quoting of GROUP!s/etc. unless they are sure they know what they're doing (wouldn't be any worse than historical properties, but we're trying to be better).

This tips the scales in favor of using ONLY for a block-making operation that consists of the single argument you give it, which @rgchris had warmed up to:

>> only 1000 + 20
== [1020]

>> only [d]
== [[d]]

This creates a little bit of friction with those wishing to use /ONLY as a refinement name. But it's not a particularly great refinement name anyway...and this problem exists for lots of words (e.g. /ALL). I've posted about the need for solutions to naming refinements out of the way.


I've changed over to this so we can try it out. No one's really gotten used to LIT anyway, and I feel pretty good about how the change to JUST looks seeing it used around in the code...so I'll see if that feeling persists.

It is not difficult to change back.

2 Likes

I'm still trying this, to see how used to it I get. The theory is that if something like this is in use for a while, you start to be able to tell whether it's more natural once the familiar answer hasn't been around for a while...

I don't know if I've gotten to total familiarity; it still seems a bit weird. However, I'm definitely starting to look at things that have LIT in them as seeming more like gibberish...

If we were going for maximum clarity, I think "literally" is the most clear:

>> append [a b c] literally d
== [a b c d]

But no one wants to write that in practice, so the reality would be that the code would have lit everywhere. So I think it's likely that JUST is a keeper.

>> append [a b c] just d
== [a b c d]