Use of floating methods, attributes and constants

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Use of floating methods, attributes and constants

Graham
I'm quite puzzled by these, but especially floating constants. In all three cases the Rexx Ref says "If no ::CLASS directive precedes ::CONSTANT, a single constant method method is created that is not associated with a class but is accessible to the main (executable) part of a program through the .METHODS built-in object" substituting method or attribute as appropriate.

What exactly does "accessible" mean? It does not appear to be possible to access the value of a floating constant for example, nor assign a value to a floating attribute.

In fact, pretty much all I've been able to do is find out if floating attributes or methods are private, guarded or protected and get their source. I've not managed to access anything for a floating constant, apart from seeing it in the .Methods directory.
Reply | Threaded
Open this post in threaded view
|

Re: Use of floating methods, attributes and constants

Jon Wolfers
I also think this does not work as designed.

Using floating constants .methods is a string table of .method objects, indexed by the constant name, but in each case, the source attribute returns an array of zero lines.

Can anyone provide a code sample showing how to use this?

thanks,

Jon

Code
===================
say '.Methods is a' .methods~class
do key over .methods
   say key': constant =' .methods~at(key)~isConstant||', items =' .methods~at(key)~source~items||', value = ['.methods~at(key)~source~makestring']'
end /* DO */

::CONSTANT FIVE 5
::CONSTANT SIX  6        
===================

Results
===================
C:\oorexx>rexx test9
.Methods is a The StringTable class
SIX: constant = 1, items = 0, value = []
FIVE: constant = 1, items = 0, value = []
===================