# Naming logic variables with a ? at the end

**URL:** <https://revolt.metaeducation.com/forum/t/naming-logic-variables-with-a-at-the-end/200>\
**Category:** Naming\
**Created:** [July 11, 2017, 8:55am UTC](https://revolt.metaeducation.com/forum/t/naming-logic-variables-with-a-at-the-end/200 "2017-07-11T08:55:53Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![hostilefork](https://revolt.metaeducation.com/forum/user_avatar/revolt.metaeducation.com/hostilefork/32/421_2.png) [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Post date:** [July 11, 2017, 8:55am UTC](https://revolt.metaeducation.com/forum/t/naming-logic-variables-with-a-at-the-end/200/1 "2017-07-11T08:55:53Z")

</div>

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. Revolt 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"

---

<div class="post-metadata">

**Author:** ![gchiu](https://revolt.metaeducation.com/forum/user_avatar/revolt.metaeducation.com/gchiu/32/22_2.png) [@gchiu](https://revolt.metaeducation.com/forum/u/gchiu)\
**Post date:** [July 11, 2017, 9:45am UTC](https://revolt.metaeducation.com/forum/t/naming-logic-variables-with-a-at-the-end/200/2 "2017-07-11T09:45:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![iArnold](https://revolt.metaeducation.com/forum/user_avatar/revolt.metaeducation.com/iarnold/32/226_2.png) [@iArnold](https://revolt.metaeducation.com/forum/u/iArnold)\
**Post date:** [July 11, 2017, 11:21am UTC](https://revolt.metaeducation.com/forum/t/naming-logic-variables-with-a-at-the-end/200/3 "2017-07-11T11:21:27Z")

</div>

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 😉 !

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.

---

<div class="post-metadata">

**Author:** ![hostilefork](https://revolt.metaeducation.com/forum/user_avatar/revolt.metaeducation.com/hostilefork/32/421_2.png) [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Post date:** [July 11, 2017, 11:43am UTC](https://revolt.metaeducation.com/forum/t/naming-logic-variables-with-a-at-the-end/200/4 "2017-07-11T11:43:08Z")

</div>

> [@gchiu](#):
>
> Length-of instead of length? harkens back to more formal computer languages which also meant less ambiguity.

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.

> [@iArnold](#):
>
> I can live with LENGTH-OF as an alias

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...

---

<div class="post-metadata">

**Author:** ![draegtun](https://revolt.metaeducation.com/forum/user_avatar/revolt.metaeducation.com/draegtun/32/230_2.png) [@draegtun](https://revolt.metaeducation.com/forum/u/draegtun)\
**Post date:** [July 11, 2017, 4:20pm UTC](https://revolt.metaeducation.com/forum/t/naming-logic-variables-with-a-at-the-end/200/5 "2017-07-11T16:20:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gchiu](https://revolt.metaeducation.com/forum/user_avatar/revolt.metaeducation.com/gchiu/32/22_2.png) [@gchiu](https://revolt.metaeducation.com/forum/u/gchiu)\
**Post date:** [July 11, 2017, 9:41pm UTC](https://revolt.metaeducation.com/forum/t/naming-logic-variables-with-a-at-the-end/200/6 "2017-07-11T21:41:03Z")

</div>

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 `?`.

---

<div class="post-metadata">

**Author:** ![hostilefork](https://revolt.metaeducation.com/forum/user_avatar/revolt.metaeducation.com/hostilefork/32/421_2.png) [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Post date:** [July 11, 2017, 9:44pm UTC](https://revolt.metaeducation.com/forum/t/naming-logic-variables-with-a-at-the-end/200/7 "2017-07-11T21:44:06Z")

</div>

> [@draegtun](#):
>
> I do aesthetically prefer LENGTH?, TYPE?, etc over LENGTH-OF & TYPE-OF.

Well in this case, we know Carl didn't do it on accident, [("he meant to do that")](https://www.youtube.com/watch?v=urnRVr1P2bc). 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... ☹

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.

---

<div class="post-metadata">

**Author:** ![BlackATTR](https://revolt.metaeducation.com/forum/user_avatar/revolt.metaeducation.com/blackattr/32/204_2.png) [@BlackATTR](https://revolt.metaeducation.com/forum/u/BlackATTR)\
**Post date:** [July 11, 2017, 11:25pm UTC](https://revolt.metaeducation.com/forum/t/naming-logic-variables-with-a-at-the-end/200/8 "2017-07-11T23:25:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gchiu](https://revolt.metaeducation.com/forum/user_avatar/revolt.metaeducation.com/gchiu/32/22_2.png) [@gchiu](https://revolt.metaeducation.com/forum/u/gchiu)\
**Post date:** [July 12, 2017, 4:42am UTC](https://revolt.metaeducation.com/forum/t/naming-logic-variables-with-a-at-the-end/200/9 "2017-07-12T04:42:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![draegtun](https://revolt.metaeducation.com/forum/user_avatar/revolt.metaeducation.com/draegtun/32/230_2.png) [@draegtun](https://revolt.metaeducation.com/forum/u/draegtun)\
**Post date:** [July 12, 2017, 10:19am UTC](https://revolt.metaeducation.com/forum/t/naming-logic-variables-with-a-at-the-end/200/10 "2017-07-12T10:19:51Z")

</div>

> [@hostilefork](#):
>
> But TYPE? bothers me in particular, because it too strongly feels like it should mean what DATATYPE? means today.

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

---

<div class="post-metadata">

**Author:** ![hostilefork](https://revolt.metaeducation.com/forum/user_avatar/revolt.metaeducation.com/hostilefork/32/421_2.png) [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Post date:** [July 13, 2017, 4:49pm UTC](https://revolt.metaeducation.com/forum/t/naming-logic-variables-with-a-at-the-end/200/11 "2017-07-13T16:49:52Z")

</div>

> [@draegtun](#):
>
> Perhaps a different word to TYPE is needed. How about KIND?

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.

---

<div class="post-metadata">

**Author:** ![draegtun](https://revolt.metaeducation.com/forum/user_avatar/revolt.metaeducation.com/draegtun/32/230_2.png) [@draegtun](https://revolt.metaeducation.com/forum/u/draegtun)\
**Post date:** [July 16, 2017, 1:21pm UTC](https://revolt.metaeducation.com/forum/t/naming-logic-variables-with-a-at-the-end/200/12 "2017-07-16T13:21:10Z")

</div>

> [@hostilefork](#):
>
> 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!

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!

```
