[Gambas-user] Backward Compatibility with gambas versions added to wiki faq
g4mba5 at gmail.com
Fri Oct 9 10:25:02 CEST 2020
Le 09/10/2020 à 09:23, Tobias Boege a écrit :
> On Fri, 09 Oct 2020, Bruce Steers wrote:
>> I do not know just "how" frequently this question is asked, but I asked it,
>> I've seen others ask it too.
>> So the wiki F.A.Q seemed a good place to put this info...
>> Please edit/add anything you think i missed. :)
> As far as I (looked up and) understood the mail by Benoît, this is a
> feature of the *compiler*, not of the runtime, right? The compiler
> supports emitting multiple bytecode versions. The interpreter supports
> running its own version and older ones, up to major version boundaries.
> I would like to know what the failure modes of this feature are.
> The options I can think of are:
> - If the differences are too big, the compiler may throw an error
> "can't compile this construct with that bytecode version".
> It will never compile to code that will not work and you get
> feedback immediately in the compilation process.
> - The compiler implements backward-compatible features as it
> normally would but only tags the file as the old bytecode
> version, causing the interpreter to potentially fail at runtime
> or silently misinterpret the code.
> I think the second mode is inevitable because parts of Gambas are
> too late-bound for the compiler to catch mismatches, but in those
> cases at least the bytecode won't be incompatible, right?
At the moment, the compiler is not very clever. It emits compatible
bytecode according to the value of GB_PCODE_VERSION only for a few
features (fast &= implementation, checking error of EXEC or SHELL
immediately, CREATE STATIC), which covers three versions of bytecode:
3.15, 3.7, and older than 3.7 (I said 3.8, but the code tells 3.7).
In other words, it can't build code for an older version of the bytecode.
The GB_PCODE_VERSION is a trick. You use it at your own risk, provided
that you know what you do.
> What happens when the bytecode format changes locally, because the
> encoding for the parameters of an instruction changes? Does that
> just never happen in a minor version update because it's Benoît's
> unwritten policy?
My rule was the old bytecode must always work with newer versions of the
bytecode. Except if the major version of Gambas changes.
> According to my casual observations, the bytecode format is treated
> like an implementation detail and that makes reasoning about the
> effect of that environment variable very hard. I would tend not to
> recommend using it in an FAQ (but the wiki should list it somewhere,
> maybe on a page about compiler/interpreter environment variables).
I agree. This must be removed from the FAQ and put it somewhere else.
More information about the User