Naming logic variables with a ? at the end

Most of the argumentation about ? has focused on things like LENGTH? becoming LENGTH-OF since it's not a LOGIC!. e.g. should ?-ending things purely be returning a logic.

Historically, I've not expressed much empathy for LENGTH? I do realize that ramming inflexible rules down people's throats about what to do with their names or symbols runs a bit counter to Rebol's mission. But somehow this particular decision felt more maddening than instructive.

Yet there's another argument, which is not as popular. (Perhaps that people don't care indicate it's not that important?) This other argument is should boolean variables, which have no parameters at all, end with a ?.

Something that made me uneasy about it at first, was how it affected reading expressions, since basically all the "in-the-box" ?-expressions were arity 1. Ren-C has shifted this a bit, by having more variance ?-ending functions (e.g. FIND? SERIES VALUE where FIND? is a CHAIN instead of FOUND? FIND SERIES VALUE). It's also thrown in expression barriers, so you can say any [my-variable? | blah blah blah] easily and not be thrown off by any [my-variable? blah blah blah].

So I'm now at the point of wondering whether to more or less endorse the idea of tagging boolean variables with ?. But just as -of has been invoked for the "it's a question, not a variable", there are other options for booleans. Like is-locked: true vs locked?: true, or was-locked: true vs. was-locked?: true.


I will say one thing, which is I'm more sympathetic to the idea of wanting to apply this convention to logic variables than I am to just putting ? on the end of functions "because they return a result"

I didn't think it was too unnatural to have a ? at the end of the word. Rebol was intended to be like a natural language, and I don't believe it was ever intended that a word ending in a ? only meant boolean. Length-of instead of length? harkens back to more formal computer languages which also meant less ambiguity.

Although length? is fairly unambiguous and returns a measurement, date? returns a boolean whether it's a date! datatype instead of a date value.

Anyway, I'm happy enough to attach a ? to a boolean variable.

While it is true that adding a questionmark after the name suggests that the returning value will be a logic! value, it is also true that the questionmark is just a convention. It is free to use a character like the questionmark in the name of a function or 'variable'.

As Graham already points out, Rebol is a language made for people to use it, and as such the exception that LENGTH? brings is easy to understand for us humans. It only occurred to me later when purists pointed out the difference here.

Personally I do not care at all that LENGTH? returns a length and not a true/false, the meaning of LENGTH? comes natural to me. I can live with LENGTH-OF as an alias and let whoever teaches Rebol or sets company standards decide that LENGTH? may not be used by their standards, as long as it will not become another unneccesary rule to obey. I would rebel against such a rule :wink: !

After all it is the programmer who is free to choose if he/she adds the ? to the name. And I think that is good enough.

This kind of thing is not too far away from "i before e except after c, and sometimes y". And the question of how much of this is the point of the project, vs. just bad design, or bad taste, remains open.

I've been trying to think of how to rethink it as a "core" and "skins". The recent definitions for TRUTHY? and FALSEY? are a good thought experiment, of how I'd like the central pieces to follow a scheme, and then we let the ecosystem fight it out. If it's as simple as truthy?: :to-logic | falsey?: :not (and it is) then I think people should be able to make up their own mind. It's only when things are overtly misleading (TRUE?, FALSE?) that someone need intervene.

So, I guess this goes back to how when we talk about "putting the personal" back into personal computing, the academic impulses that folks like me and @earl have, should find the balance. It's important there be a correct and rational core, but not to the extent that the language loses its freeform encouragement...

On of the things I do in my %user.reb is...

type?: :type-of

...because I do aesthetically prefer LENGTH?, TYPE?, etc over LENGTH-OF & TYPE-OF. It does feel more Rebolish to me.

I have no issue with word ending in ? being a "what is its" (LENGTH?) or "is it a" (DATE?) question or just logic variable (locked?) and already used all 3 variants in programs I've written.

I totally appreciate where you're coming on this and with IF?, FIND?, PARSE?, etc. I'm afraid no easy answer to this as it may always come down to taste.

The issue I have with that is that you have to rename before you distribute scripts.

I do appreciate the clarity though of using -of as sometimes I would write length when I meant length? as I couldn't always remember which words ended in a ?.

Well in this case, we know Carl didn't do it on accident, ("he meant to do that"). And the Red camp has been stalwart about sticking to the choice. And for whatever it is worth, I am less in the "purist" camp for this kind of thing than I used to be.

But TYPE? bothers me in particular, because it too strongly feels like it should mean what DATATYPE? means today. I was hoping that type-of integer! could be TYPE!, and type? integer! would be true. And I think ANY-CONTEXT? INTEGER! should be true, and... :frowning:

I can see both sides, and it's not like you can't do as you've done and overrule the core in your scripts. I think, maybe, what your work has been doing in terms of helping people customize their environment can help take away the pain of not doing things the "purist" way. But maybe in the long run, keeping the innards of the system purist and letting these questionable decisions be personal ones is best.

And then on the other hand you have a function like what-dir, which seems like due to way its named it ought to have a question mark.

I guess we have to remember which convention is being applied where. OS access now uses bash names like pwd.

Perhaps a different word to TYPE is needed. How about KIND? There's even an interesting case for MAKE?

Well, then I'd expect KIND? to return a KIND!, not a TYPE!.

I actually have been thinking that KIND would be different, helping to account for the difference between a fundamental type, and a user datatype. KIND-OF MY-BOOK could be OBJECT!, while TYPE-OF MY-BOOK could come back as BOOK!, and TYPE-OF BOOK! could be TYPE!.

Anyway, we've veered off into the question I knew was more controversial (ending-in-?-needs-to-mean-returns-LOGIC!) vs. the other question of naming variables that are LOGIC!, but aren't functions. @earl was against it, I felt like it might be bad too, but now I think it's okay, since you have expression barriers to communicate if you feel it's ambiguous.

Knowing what your object was MADE from is something I did originally have in my previous comment but edited out.

So yes I think this having something like this could be very handy...

>> book!: make object! [...]

>> some-book: make book! [...]

>> make? book!
== object!

>> make? some-book
>> book!