Since the discussion seems to be revived, I would like here to give my opinion again about the further development (see my request above).
In its current implementation in FB, a reference can be re-initialized to refer to another object (but of compatible type), and that like few other languages and unlike many other languages, but I agree to keep as much flexibility as with pointers.
Presently, a reference can also be re-initialized to refer to nothing, a "null" reference (@ref = 0), and this can be done even at the level of its declaration:
Code: Select all
Dim As Integer i1, i2
Dim Byref As Integer ref1 = i1
'' reference re-initialized
@ref1 = @i2
'' reference re-initialized to a "null" reference
@ref1 = 0
'' reference directly initialized to a "null" reference at declaration level
Dim Byref As Integer ref2 = *Cptr(Integer Ptr, 0)
Presently one can also pass/return to/from a procedure a "null" reference by using '*Cptr(datatype Ptr, 0)', or even the short-cut syntax 'Byval 0'.
I would even be in favor of possibility of declaring more simply a "null" reference (@ref = 0) by authorizing a declaration without any initializer:
'Dim Byref As datatype ref'
This would simplify the further development to be able to:
- declare a reference as a UDT member,
- declare a dynamic array of references.
Additional functionality to implement for consistency with the authorization of a "null" reference:
- add the null-pointer check on the internal pointer of the reference when compiling with the '-exx' option.