Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Include statement #62

Open
Tetr4 opened this issue Mar 16, 2017 · 0 comments
Open

Support for Include statement #62

Tetr4 opened this issue Mar 16, 2017 · 0 comments
Labels

Comments

@Tetr4
Copy link
Member

Tetr4 commented Mar 16, 2017

The specification says, that variables are declared when they are first used, and that if a variable is used before it is assigned a value, then its value is NULL.
Currently Arden2ByteCode purposely checks for usage of undefined variables and shows an error at compile-time. This is helpful, as using a variable, before it holds a value is usually a user-error and not what is intended, e.g. a mistyped variable name.

The INCLUDE statement allows pulling variable definitions from other MLMs at runtime:

other_mlm := MLM 'other_mlm';
INCLUDE other_mlm;
p := NEW Patient WITH "John Doe";  // Patient object is defined in other_mlm

This only works for special variables:

  • MLM
  • event
  • interface
  • object
  • resource (≥v2.6)

As shown above, the Patient object definition is not known at compile-time. Supporting the INCLUDE statement, is therefore at odds with using undefined variable checks at compile-time.

There are multiple approaches to this problem:

  • Let checks only apply to normal variables, not special variables. Special variables can not be used in normal expressions (e.g. 5 + other_mlm), as this leads to a compile-time error. This doesn't work for event variables though, as they can be used like booleans (IF my_event THEN …).
  • Other MLMs are included at compile-time, like in C #include directives. This is a bit awkward as MLMs may be called at run-time and therefore need to be present at compile-time and runtime. It also doesn't mix well with Javas classloading concept which allows loading (MLM-)classes at runtime.
  • Undefined variables return NULL. This is more conforming to the specification. Undefined variable checks could still apply as long as no INCLUDE statement has occurred before. Checks could also be deactivated via a command line flag.
@Tetr4 Tetr4 added the Notes label Mar 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant