Author Topic: Why _MEM.OFFSET?  (Read 3519 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Why _MEM.OFFSET?
« on: July 22, 2018, 08:33:17 am »
So here's a question:  Why was the Mem commands built to use m.OFFSET as the second parameter?  What's the purpose/reason for it?  Why not have it work inherently behind the scene??

For example, why do we need to _MEMGET m, m.OFFSET + 100, var?  Why wasn't it made to just be _MEMGET m, 100, var?

Think of it in comparison to using GET from a file...   We GET #1, 100, var; we don't need to GET #1, #1.OFFSET + 100, var....

I know _MEM has been around and has been used in too many programs to change its syntax so much now, but is there a reason for m.OFFSET being there that I'm just overlooking?  We're *always* going to reference memory from the start of a memblock, so shouldn't QB64 have just added _MEM.OFFSET to whatever pointer/variable we sent it, behind the scenes, and saved the programmer from ever having to type it out or worry about it??

I'm just curious if anyone knows why it is the way it is, and if there's just an obvious reason for it that I'm overlooking.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SkyCharger001

  • Newbie
  • Posts: 14
    • View Profile
Re: Why _MEM.OFFSET?
« Reply #1 on: July 22, 2018, 08:49:56 pm »
I think it's to allow us to control when the lookup is performed, instead of doing it every cycle or whenever the _mem-functions are called. (even the ones that never need the lookup.)