Case Study of Case Behavior: The AN Function

In thinking about weird applications of case, I was reminded of the little trick of the AN function:

>> an "integer"
== "an integer"

>> an "text"
== "a text"

It simply checks the letters of the start of the rendering of what comes after it, and resolves to either "a" or "an". I came up with it during the automatic generation of help strings for typecheckers, something along the lines of:

for-each type data-types [
    help-string: spaced ["Checks to see if value is" an mold type]

But what if the A or An is at the start of a sentence? Wouldn't the case of the operator matter?

>> An "integer"
== "An integer"

Or how about all-caps?


In a case-insensitive world, all of these calls are to the same function. So what it had to do was consult the stack to see what the label was it was invoked with, and go by the case of that.

But in a case-sensitive world, these would be three different functions (most likely, specializations of a core AN* that took what casing you wanted).

I'm not sure where this fits in the @Mark-hi taxonomy of rightness or wrongness. But it does point to an axis of flexibility where someone can use stack reflection to force case-sensitive behavior in a case-insensitive system.

1 Like

Seems like the best of both worlds to me! Awesome stuff HF.

I wonder if a plural equivalent would be useful too?

>> some "integer"
"some integers"


>> some "text"
"some text"

Neat idea, though it's not as uniform a linguistic rule... ("an albatross")