With my bolstered confidence that FILE! best serves as a non-string, I feel like it gives a certain amount of irresistable power.
>> size of %foo.dat == 143983 ; size of the foo.dat file on disk
(Note: My thinking on SIZE with strings is that it gives you a count in bytes, whereas LENGTH gives you a count in codepoints. This distinction of "length is logical units" and "size is a byte count" has precedent in other systems...but I'd like to go through and make sure that it's being used consistently everywhere. A BINARY! can use either since its logical size is 1, but I'd prefer to speak in terms of the size where possible...e.g. when the binary is not being discussed in the context of a generic length that would apply to any series)
Somewhat extremely, this would suggest I'd be saying that length of %foo.dat would be something that would delegate to whatever the port type was for that file...and give back the logical length of the contents.
; contents of %foo.myformat [record 1 "foo" #bar] [record 2 "baz" #mumble] >> length of %foo.myformat == 2
We're imagining here that you're living in a world where a "myformat" port would act something like:
>> p: open %foo.myformat >> read/part p 1 == make object! [ x: "foo" y: #bar ] >> read/part p 1 == make object! [ x: "baz" y: #mumble ] >> read/part p 1 ; null
Of course I am making this all up. But what I'm trying to get at is that when you want to talk about the attributes of something that is a representation of some grand thing, the number of characters in its name is potentially much less interesting than all the logical things you can ask about it.
That said...it should be easy to ask how long the name is. And this is a little bit ugly:
>> length of as text! %foo.dat == 7
In the API I've used the word "spell" to talk about string extraction. Might that look nicer?
>> spell %foo.dat == "foo.dat" >> length of spell %foo.dat == 7
I guess it could also be FORM. Though FORM never quite sat right with me, I don't think of it so much as a verb in computer programming as a noun for "form you fill out".
Anyway, this is just to throw out there the idea of SPELL as a way to ask for the underlying string of something that may look a bit better than AS TEXT!.