Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Requests and Feedback

Procedure type in procedure parameters

A community discussion post from the original code:zIRON forum.

Replies

0CodErr member
Posts
201
Threads
37
Location
Unknown
Functions must have a return type declared.

But currently we cannot write:

function  X() {
  function* MyProc() : sysword;
  if (MyProc() > 0) {}
  return true;
}

only allowed:

function  X() {
  function* MyProc() : sysword;
  gp_ax = MyProc();
  if (gp_ax > 0) {}
  return true;
}

And in this case type of 'gp_ax' used.

Also in usual functions we did not write type of them.

But if we really will use type of function then it of course good idea :)

Colin admin
Posts
928
Threads
49
Location
Bulgaria

I have been considering options of adding types to functions using a similar C like syntax, but this is on my "undecided" list for now.

0CodErr member
Posts
201
Threads
37
Location
Unknown

It is possible to do it by analogy with:

function* MyProc() : sysword;

i.e. by this way:

function MyProc() : sysword; {
  sysword tmp;
// ..............  
  return tmp;
}
Colin admin
Posts
928
Threads
49
Location
Bulgaria

I thought about this way, but I was uncomfortable with the syntax

type; {
Colin admin
Posts
928
Threads
49
Location
Bulgaria

Options are:

function WINAPI MyProc(par1, par2, par3): sysword {
  //
}
function WINAPI MyProc: sysword(par1, par2, par3) {
  //
}
function WINAPI sysword MyProc(par1, par2, par3) {
  //
}
// c-type (not really suitable as i planned to use this format for very high level functions)
sysword WINAPI MyProc(par1, par2, par3) {
  //
}
sysword MyProc = WINAPI function(par1, par2, par3) {
  //
}
function WINAPI MyProc(par1, par2, par3) {
  //
}: sysword;
function:sysword WINAPI MyProc(par1, par2, par3) {
  //
}
0CodErr member
Posts
201
Threads
37
Location
Unknown

As for me then #1 and #6 seems are good variants.

But advantage of #1 that we can distinguish type at the beginning of function.

Also i would like to pay attention that if we will add in future some other parameter then we maybe need to use semicolon. Like this:

function WINAPI MyProc(par1, par2, par3) : sysword; forward; noframe; some_other_param; ...; ...; ...; {
  //
}
Colin admin
Posts
928
Threads
49
Location
Bulgaria

OK maybe I will give it a try this way and see how it goes. I've added [post 1792] type #1 to my todo list.

Colin admin
Posts
928
Threads
49
Location
Bulgaria

This is implemented for next release.