Very confusing: when is "length" a number and when is it a "length"?

Can somebody please explain to me what the hell is going on here?

tell application “Mail”
set theMailbox to mailbox “Deleted Messages” of account “richcook.net
set theMessages to messages of theMailbox
log (class of theMessages)
log (length of theMessages)
log (“end of theMessages”)
log (class of messages of theMailbox)
log (length of messages of theMailbox)
log (length of messages in mailbox “Deleted Messages” of account “richcook.net”)
end tell

in the log I see:
tell application “Mail”
get mailbox “Deleted Messages” of account “richcook.net
mailbox “Deleted Messages” of account “richcook.net
get every message of mailbox “Deleted Messages” of account “richcook.net
(list)
(4648)
(end of theMessages)
(class)
(length)
(length)
end tell
HUH? Why is the length of theMessages the only thing that gets a number? What is going on? Exactly what kind of thing is it that is returned by “messages of theMailbox”? I am really confused here.
Thanks for a sane explanation! Please!

AppleScript: 1.1
Browser: Safari) OmniWeb/v563.42
Operating System: Mac OS X (10.4)

Some apps work differently with filter references. I didn’t tested, but most probably it will work as it should if you use a explicit “get”. Eg:

log (class of (get messages of theMailbox))

Browser: Safari 312
Operating System: Mac OS X (10.3.7)

Thanks, interesting. You are right. Your suggestion worked. I thought it was a nuance of Applescript I was missing, but it sounds as if Mail is not properly obeying some Applescript conventions. At least I can understand it if I can say “this is a bug in Mail.”

AppleScript: 1.1
Browser: Safari) OmniWeb/v563.42
Operating System: Mac OS X (10.4)

Just for completeness, I thought I would post the surprising results:
tell application “Mail”
set theMailbox to mailbox “Deleted Messages” of account “richcook.net
set theMessages to messages of theMailbox
log (class of theMessages)
log (length of theMessages)
log (“========================================”)
log (class of (messages of theMailbox))
log (length of (messages of theMailbox))
log (“========================================”)
log (class of (get messages of theMailbox))
log (length of (get messages of theMailbox))
log (“========================================”)
log (length of messages in mailbox “Deleted Messages” of account “richcook.net”)
log (“========================================”)
end tell

Event Log:

tell application “Mail”
get mailbox “Deleted Messages” of account “richcook.net
mailbox “Deleted Messages” of account “richcook.net
get every message of mailbox “Deleted Messages” of account “richcook.net
(list)
(4663)
(========================================)
(class)
(length)
(========================================)
get every message of mailbox “Deleted Messages” of account “richcook.net
(list)
get every message of mailbox “Deleted Messages” of account “richcook.net
(4663)
(========================================)
(length)
(========================================)
end tell

AppleScript: 1.1
Browser: Safari) OmniWeb/v563.42
Operating System: Mac OS X (10.4)