[Info-vax] VMS Basic and quad by value
Dave Froble
davef at tsoft-inc.com
Sat Sep 24 19:54:15 EDT 2022
On 9/24/2022 6:57 PM, Arne Vajhøj wrote:
> On 9/23/2022 9:09 PM, Dave Froble wrote:
>> On 9/23/2022 6:45 PM, Arne Vajhøj wrote:
>>> On 9/23/2022 4:45 PM, Bill Gunshannon wrote:
>>>> On 9/23/22 16:37, Arne Vajhøj wrote:
>>>>> I am not good at Basic so I may be missing something obvious.
>>>>>
>>>>> As I read the manual then I should be able to pass a quad by value.
>>>>>
>>>>> But the compiler disagrees.
>>>>>
>>>>> Can anybody shed some light on this?
>>>>>
>>>>
>>>> Can you show us the code?
>>>
>>> Sure.
>>>
>>> $ type z1.bas
>>> program z1
>>>
>>> declare quad v
>>>
>>> v = 123
>>> call f(v)
>>
>> You do realize, I hope, that you are passing the variable by reference?
>
> No. I don't.
>
> :-)
>
>>> end program
>>> !
>>>
>>> sub f(quad a by value)
>>
>> I tried this. It appears that Basic does not allow an argument to be declared
>> QUAD and received By Value. I'd consider this a bug.
>
> Given that the docs claims it should work, then it must
> be a bug.
>
> And I believe the compiler should be fixed not the documentation,
> because on Alpha, Itanium and x86-64 there is no reason not to
> allow it.
>
>
>> However, to demonstrate:
>>
>> AS800> t z5.bas,z6.bas
>> 1 ! Program Z5
>>
>> Declare Quad Q
>>
>> Q = 123
>> Call Z6( Q )
>> Print Q
>>
>> End
>>
>> SYS$SYSDEVICE:[DFE]Z6.BAS;4
>>
>> 1 ! Program Z6
>>
>> Sub Z6( Long L By Value )
>>
>> Print L
>>
>> End Sub
>> AS800> run z5
>> 2061851336
>> 123
>> AS800>
>>
>> As expected, the value of the argument is the address of the quadword variable
>> in program Z5.
>
> Two compilation units. I only had one.
I never do that ...
> It seems to work with long.
>
> $ typ z2.bas
> program z2
>
> declare quad v
>
> v = 123
> call f(v)
>
> end program
> !
>
> sub f(quad a)
>
> print a
>
> end sub
> $ bas z2
> $ lin z2
> $ r z2
> 123
>
> Apparently the Basic compiler do look ahead in the compilation unit.
I doubt that. Note that in this last example, you did not attempt to declare
the argument in the sub statement to be declared by value.
--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. E-Mail: davef at tsoft-inc.com
DFE Ultralights, Inc.
170 Grimplin Road
Vanderbilt, PA 15486
More information about the Info-vax
mailing list