如何将对象传递给 ooRexx 中的函数?

How do I pass objects to functions in ooRexx?

我是一名资深大型机 Rexx 程序员,正在尝试 ooRexx 中的对象。结果令人惊讶。例如,这里有一个程序:

#!/usr/bin/rexx

a = .number~new(3.14)

say "a =" a
say "a~val =" a~val

call say_number a

exit 0

say_number:
procedure
parse arg num

    say "In say_number"
    say "num =" num
    say "num~val =" num~val

return

::class number public

::attribute val get public

::method init   ; expose val ; use arg val
::method new    ; expose val ; use arg val
::method string ; return "'"self~val"'"

结果是:

> number
a = '3.14'
a~val = 3.14
In say_number
num = '3.14'
    18 *-*   say "num~val =" num~val
     8 *-* call say_number a
REX0097E: Error 97 running /home/tony/bin/.scripts/number line 18:  Object method not found
REX0476E: Error 97.1:  Object "'3.14'" does not understand message "VAL"

似乎在将对象传递给 say_number 函数之前将其解析为其字符串值。诡异的!我是否漏掉了一些明显的东西?

好吧,没花多长时间。我在函数中将 parse 更改为 use,一切都按预期进行。根据参考手册:

USE ARG retrieves the argument objects provided in a program, routine, function, or method and assigns them to variables or message term assignments.

PARSE assigns data from various sources to one or more variables according to the rules of parsing. ... If you specify UPPER, the strings to be parsed are translated to uppercase before parsing. If you specify LOWER, the strings are translated to lowercase. Otherwise no translation takes place.

推测 PARSE 将参数转换为字符串,以便它可以根据要求(或默认)更改大小写。