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

Feature: Direct parameter reference of functions and procedures. #105

Open
GSoftwareDevelopment opened this issue Jun 10, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@GSoftwareDevelopment
Copy link
Contributor

GSoftwareDevelopment commented Jun 10, 2022

Currently, passing parameters to functions and procedures is performed by creating local variables for them. This solution is good and safe, but it generates the code needed to assign the values of passed variables to the local variables of the procedure/function.

My suggestion is to be able to pass a parameter as a direct reference - something like 'var' but without creating a local variable, i.e. a global variable, but inside the block, would be represented by an individual name.
You could use a modifier, e.g. & or a textual ref or as reference, which would be presented in the code e.g.

procedure Opn(&chn,&ax1,&ax2:byte @device:PString);

or

procedure Opn(ref chn,ax1,ax2:byte ref device:PString);

or

procedure Opn(chn,ax1,ax2:byte as reference; device:PString as reference);

The example of the CIO.Opn(chn, ax1, ax2: byte; device: PByte); procedure is here for a reason. Using this procedure is a double rewrite of information:

  1. from the contents of the passed parameters to the procedure;
  2. inside the procedure, where local variables are "plugged" into the IOCB block.

This is not the only case where such a solution would shorten the resulting code.

Technically, this would be done by replacing the address of the variable used as a direct reference. I don't know how much the compiler design would allow you to do this?

The plus side of this approach, is the clarity that the block accepts parameters. You don't have to parse the code to know that global variables must be set before using such a function or procedure.
An additional advantage is not rewriting the parameters to local variables - the programmer decides for himself.

@zbyti zbyti added the enhancement New feature or request label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants