Menu

ABSOLUTE madness?

2019-06-10
2019-06-11
  • Yet Another Troll

    Can ABSOLUTE be used to alias a variable as an array element?

    Can ABSOLUTE be used with string variables? Maybe even alias LOCAL string variables to elements of string arrays passed by VAR? And assign or SWAP through the aliases?

    Could one array be an ABSOLUTE alias for a sub-range in another array, such that LOCAL B$() 0 through r%-l% would be a bounds checked alias for VAR A$() l% through r%, so that attempts to access elements of B$() before 0 or past r%-l% would be an error and changes to elements of B$() such as SWAP B$(0), B$(1) would be reflected in A$(l%) and A$(l% + 1) and vice-versa?

    I'm asking for my friends, Hoare, Sedgewick, and Bentley.

     
  • Yet Another Troll

    Could ABSOLUTE aliasing LOCAL variables to substrings or lvalue MID$ of a VAR string be a back door to UDTs? X% becomes MID$(S$, 1, 4), Y MID$(S$, 5, 8), Z&() would be MID$(S$, 13, ???) What happens when I then go and DIM Z&(UBOUND(Z&()) * 2 + 1024) ?

    Why are you backing away slowly like that?

     

    Last edit: Yet Another Troll 2019-06-11
  • Markus Hoffmann

    Markus Hoffmann - 2019-06-11

    I would not do that. I might work, but you would discover several bugs or at least strange behaviours of X11-Basic. Remember it is about pointers only. No real aliases of variables.

     
  • Markus Hoffmann

    Markus Hoffmann - 2019-06-11

    For array bounds checking you should use ARRPTR() on that array, e.g.

    DIM a(100,200)
    adr%=ARRPTR(a())
    dimension=LPEEK(adr%)
    p%=VARPTR(a(0))
    print lpeek(p%-dimension*8)
    print lpeek(p%-dimension*8+4)
    

    But this is undocumented internals and may change in future....

     
    • Yet Another Troll

      Yeah, OPTION BASE 1 or any eventual arbitrary lower/upper bounds support would b0rk that hard. No thanks. I at least try to stick to documented behavior.

       

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.