fxm wrote:Is the 'Dimbyref' development is now stopped in its present capability?
I hoped a wider usage for this new feature, as discussed in the previous posts.
IMHO, the following capacities to be maintained and to be added in the future upgrades:
- Add the arrays of references (useful for a collection of compatible objects):
Dim Byref As datatype ra(...) = {...}
- Keep the present capacity to define that I name "empty references" (with associated internal null pointers):
Dim Byref As datatype ref = *Cast(datatype Ptr, 0)
or:
@ref = 0
or:
Return *Cptr(datatype Ptr, 0)
or:
Return Byval 0
- Before usage, the case "empty reference" can be checked by:
If @ref <> 0 Then .....
- Extend that capacity of "empty references" by means of a shorter definition without initializer, useful for big or un-sized reference arrays (with associated internal null pointers):
Dim Byref As datatype ref
Dim Byref As datadype ref(...)
- Adds the null-pointer checking (on the internal pointer) when compiling with -exx option.
- Authorise the implict conversions between references of compatible pointeur types:
Dim Byref As Integer Ptr ref = Cast(Any Ptr, 0)
or:
Dim Byref As Any Ptr ref = Cast(Integer Ptr, 0)
- Add a new specific operator, for example '{}' (reference index) to return a reference to a value some distance in memory from a base address (shortness syntax):
ref{i} = (@ref)
example:
Dim Byref As Integer ref = *New Integer[10]
Print ref{5} '' equivalent to Print (@ref)[5]
Delete @ref