brightscript 函数的默认 Return 行为是什么?

What's the default Return behavior for a brightscript function?

所以我查看了一个较旧的 brightscript 代码库,发现了一堆 functions 返回的东西,但没有指定返回的内容 as

例如:

function logMessage(prefix as string, message as string)
  concatenatedMessage = prefix + message

  if m.top.logLevel <= m.top.verbosity
    print concatenatedMessage
  end if
  return concatenatedMessage
end function

那么这里发生了什么?很明显,一个字符串正在被发回,那么它的行为是否与它被声明为 function logMessage(prefix as string, message as string) as string 时完全一样?或 as object?

我一直有(错误的?)印象,如果您从函数中停止 as _____,它们默认为 as void,与 sub 相同。但这是有效的,我只是不确定如何?

由于 BrighScript 支持动态类型(如 JavaScript),函数的默认 return 类型是 "Dynamic".

来自docs

The return type of the function may also be declared. If the parameter or return type are not declared, they are assumed to be "dynamic"